Here you can find the source of writeStringToFile(String fullPath, String content)
public static boolean writeStringToFile(String fullPath, String content)
//package com.java2s; //License from project: Apache License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Writer; public class Main { public static boolean writeStringToFile(String fullPath, String content) { try {//from w ww . j a v a 2 s . com Writer output = null; File file = new File(fullPath); if (!file.exists()) { file.createNewFile(); } output = new BufferedWriter(new FileWriter(file)); output.write(content); output.close(); } catch (IOException ex) { ex.printStackTrace(); return false; } return true; } /** * Closes InputStream and/or OutputStream. It makes sure that both streams * tried to be closed, even first throws an exception. * * @throw IOException if stream (is not null and) cannot be closed. * */ protected static void close(InputStream iStream, OutputStream oStream) throws IOException { try { if (iStream != null) { iStream.close(); } } finally { if (oStream != null) { oStream.close(); } } } }