List of utility methods to do Text File Write
void | writeStringToFile(String f, String s, boolean append) Write a string to file - CSV Format try { String filename = f; FileWriter fw = new FileWriter(filename, append); fw.write(s); fw.write("\n"); fw.close(); } catch (IOException io) { System.err.println("IOException: " + io.getMessage()); ... |
void | writeStringToFile(String file, String data, boolean append) Write string to file. FileWriter fstream; try { fstream = new FileWriter(file, append); BufferedWriter out = new BufferedWriter(fstream); out.write(data); out.close(); } catch (IOException e) { e.printStackTrace(); ... |
void | writeStringToFile(String file, String str, boolean append, boolean newLine) Write/append a string to a file. try { FileWriter fw = new FileWriter(file, append); fw.write(str); if (newLine) { fw.write("\n"); fw.close(); } catch (IOException ioe) { ... |
void | writeStringToFile(String fileName, String content) write String To File FileWriter fileWriter = null; try { File newTextFile = new File(fileName); fileWriter = new FileWriter(newTextFile); fileWriter.write(content); fileWriter.close(); } catch (IOException ex) { throw new RuntimeException(ex); ... |
void | writeStringToFile(String filename, String content) write String To File File file = new File(filename); PrintWriter pw = new PrintWriter(new FileOutputStream(file)); pw.print(content); pw.close(); |
boolean | writeStringToFile(String fileName, String src) write String To File if (src == null) { src = ""; boolean isOk = true; FileWriter out = null; try { out = new FileWriter(fileName); out.write(src); ... |
void | writeStringToFile(String filename, String str) write String To File writeStringToFile(filename, str, false); |
void | writeStringToFile(String fileName, String str, boolean isAppend) write String To File BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName, isAppend))); try { bw.write(str); bw.flush(); } finally { bw.close(); |
void | writeStringToFile(String filename, String string) Writes a string to a file. BufferedWriter out = new BufferedWriter(new FileWriter(filename)); out.write(string); out.close(); |
void | writeStringToFile(String filename, String string, boolean overwrite) write String To File File destFile = new File(filename); try { if (destFile.exists()) { if (overwrite) destFile.delete(); else return; destFile.createNewFile(); Writer outputStream = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(destFile), "UTF-8")); outputStream.write(string); outputStream.close(); } catch (IOException e) { e.printStackTrace(); |