Java FileWriter Write saveAllToFile(String filename, String... strings)

Here you can find the source of saveAllToFile(String filename, String... strings)

Description

save All To File

License

LGPL

Declaration

public static boolean saveAllToFile(String filename, String... strings) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Main {
    public static boolean saveAllToFile(String filename, String... strings) {
        return saveAllToFile(new File(filename), strings);
    }//from   ww  w .j  a  v  a  2  s.c om

    public static boolean saveAllToFile(File file, String... strings) {
        try {
            FileWriter fw = new FileWriter(file);

            for (String s : strings) {
                fw.write(s);
            }

            fw.flush();
            fw.close();

            return true;
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("Saving to file " + file.getName() + " failed! Aborting shut down...");
            return false;
        }
    }
}

Related

  1. save(String modelo, String filename)
  2. save(String targetDir, String filename, String textToSave)
  3. save2DArray(float[][] data, String filePath)
  4. save2File(String fileName, String content)
  5. save_array(double[] array, String fname)
  6. saveArrayNames(int[] array, String[] names, String fname)
  7. saveAuthFile(String fileName, String raw)
  8. saveBufferInFile(String buffer, File filename)
  9. saveCCS(Map contributionScore, String diseaseState, String file)