Java Text File Write writeStringToFile(String stringContent, String fileName)

Here you can find the source of writeStringToFile(String stringContent, String fileName)

Description

* Output string to file ******************************************.

License

Open Source License

Parameter

Parameter Description
stringContent the string content
fileName the file name

Exception

Parameter Description
Exception the exception

Declaration

public static void writeStringToFile(String stringContent, String fileName) throws Exception 

Method Source Code

//package com.java2s;

import java.io.PrintWriter;

public class Main {
    /**//from w ww.  j  a  v  a  2  s.c o  m
     * *****************************************
     * Output string to file
     * ******************************************.
     *
     * @param stringContent the string content
     * @param fileName the file name
     * @throws Exception the exception
     */
    public static void writeStringToFile(String stringContent, String fileName) throws Exception {

        PrintWriter printOut = new PrintWriter("c:\\temp\\" + fileName);
        printOut.println(stringContent);
        printOut.close();
    }
}

Related

  1. writeStringToFile(String string, File file)
  2. writeStringToFile(String string, File file)
  3. writeStringToFile(String string, String fileName)
  4. writeStringToFile(String string, String fileName, boolean append)
  5. writeStringToFile(String string, String path)
  6. writeStringToFile(String stringToBeWritten, String filePath)
  7. writeStringToFile(String stringToWrite, String fileName)
  8. writeStringToFile(String text, File file)
  9. writeStringToFile(String text, String file)