Java Text File Write writeString(final String output, final String fileName)

Here you can find the source of writeString(final String output, final String fileName)

Description

Writes string to file

License

Open Source License

Parameter

Parameter Description
output String content of the file
fileName full path of the file

Exception

Parameter Description
FileNotFoundException if the file path cannot be found.
UnsupportedEncodingException an exception

Declaration

public static void writeString(final String output, final String fileName)
        throws FileNotFoundException, UnsupportedEncodingException 

Method Source Code

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

import java.io.FileNotFoundException;

import java.io.PrintWriter;

import java.io.UnsupportedEncodingException;

public class Main {
    /**/*from  w w  w  . j ava2 s . c  om*/
     * Writes string to file
     * 
     * @param output String content of the file
     * @param fileName full path of the file
     * @throws FileNotFoundException if the file path cannot be found.
     * @throws UnsupportedEncodingException 
     */
    public static void writeString(final String output, final String fileName)
            throws FileNotFoundException, UnsupportedEncodingException {
        PrintWriter out = new PrintWriter(fileName, "US-ASCII");
        out.print(output);
        out.close();
    }
}

Related

  1. writeString(File outputFile, String text)
  2. writeString(FileWriter fw, String s)
  3. writeString(final ObjectOutput objectOut, final String str)
  4. writeString(final ObjectOutput out, final String s)
  5. writeString(final String data, final int length, final byte[] destination, int offset)
  6. writeString(final String s, final File f)
  7. writeString(String a, String MyFilePath)
  8. writeString(String content, String path, String charset)
  9. writeString(String contents, File file)