Java Text File Write writeStringToFile(String f, String s, boolean append)

Here you can find the source of writeStringToFile(String f, String s, boolean append)

Description

Write a string to file - CSV Format

License

Open Source License

Parameter

Parameter Description
f - file to write to
s - string to write
append - append to end condition

Exception

Parameter Description
IOException an exception

Declaration

public static void writeStringToFile(String f, String s, boolean append) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**/*from  w  w w. j  a  v  a  2s.c o  m*/
     * Write a string to file - CSV Format
     * @param f - file to write to
     * @param s - string to write
     * @param append - append to end condition
     * @throws IOException
     */
    public static void writeStringToFile(String f, String s, boolean append) throws IOException {
        try {
            String filename = f;
            FileWriter fw = new FileWriter(filename, append);
            fw.write(s);
            fw.write("\n");
            fw.close();
        } catch (IOException io) {
            System.err.println("IOException: " + io.getMessage());
        }
    }
}

Related

  1. writeStringToFile(String contents, File outputFile)
  2. writeStringToFile(String contents, String path)
  3. writeStringToFile(String contents, String path, String encoding)
  4. writeStringToFile(String data, String filename, boolean append)
  5. writeStringToFile(String data, String filepath)
  6. writeStringToFile(String file, String data, boolean append)
  7. writeStringToFile(String file, String str, boolean append, boolean newLine)
  8. writeStringToFile(String fileName, String content)
  9. writeStringToFile(String filename, String content)