Java Text File Write writeStringFile(String FileName, String text)

Here you can find the source of writeStringFile(String FileName, String text)

Description

Write text to a file called Filename

License

Apache License

Parameter

Parameter Description
Filename non-null name for the file

Declaration

public static void writeStringFile(String FileName, String text) 

Method Source Code

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

import java.io.*;

public class Main {
    /**/*from   w  w w.  j  a  v a2s. c o  m*/
       Write text to a file called Filename
       @param Filename non-null name for the file
       @paream text - text as contents - a cr will be added on the end
     */
    public static void writeStringFile(String FileName, String text) {
        try {
            FileOutputStream fs = new FileOutputStream(FileName);
            PrintStream out = new PrintStream(fs);
            out.println(text);
            out.close();
        } catch (IOException ex) {
            throw new IllegalArgumentException(ex.toString()); // should not happen
        }
    }
}

Related

  1. writeString(String s, File output, String encoding)
  2. writeString(String string, ObjectOutput out)
  3. writeString(String value)
  4. writeString(StringBuilder out, CharSequence value, boolean escapeXML)
  5. writeStringField(String name, String value, JsonGenerator jgen)
  6. writeStringInto(String s, File outputFile)
  7. writeStringInto(String s, File outputFile)
  8. writeStringListToFile(File file, ArrayList lines)
  9. writeStringListToFile(File file, List lines)