Java PrintWriter Write saveStringToFile(String text, String path)

Here you can find the source of saveStringToFile(String text, String path)

Description

save String To File

License

Open Source License

Declaration

public static void saveStringToFile(String text, String path) 

Method Source Code


//package com.java2s;
import java.io.*;

public class Main {
    public static void saveStringToFile(String text, String path) {
        PrintWriter writer = null;
        try {/*from  w  ww  . j  av  a  2s  .  c o  m*/
            writer = new PrintWriter(path, "UTF-8");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        writer.write(text);
        writer.close();
    }
}

Related

  1. saveStringAsFile(String string, String path)
  2. saveStringBufferTofile(String fileName, StringBuffer sb)
  3. saveStrings(final String filename, final String[] sArray)
  4. saveStrings(String filename, String data[])
  5. saveStrings(String theFilePath, String[] theStrings)
  6. saveToFile(String buf, String fileName)
  7. saveToFile(String path, String data)