List of utility methods to do Text File Write
void | writeStringToFile(File file, String data, String encoding) Writes a String to a file creating the file if it does not exist. if (encoding == null) { throw new IllegalArgumentException("Must specify encoding"); OutputStream out = null; try { out = openOutputStream(file); if (data != null) { out.write(data.getBytes(encoding)); ... |
void | writeStringToFile(File file, String data, String encoding) Writes a String to a file creating the file if it does not exist. OutputStream out = new FileOutputStream(file); try { write(data, out, encoding); } finally { closeQuietly(out); |
void | writeStringToFile(File file, String data, String encoding) Writes data to a file. OutputStream out = new java.io.FileOutputStream(file); try { out.write(data.getBytes(encoding)); } finally { closeQuietly(out); |
void | writeStringToFile(File file, String s) write String To File try (PrintStream out = new PrintStream(new FileOutputStream(file, false))) { out.print(s); |
void | writeStringToFile(File file, String str, boolean compress) Write the given String to the File. OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); if (compress) { out = new GZIPOutputStream(out); PrintWriter pout = new PrintWriter(out); pout.print(str); pout.flush(); pout.close(); ... |
void | writeStringToFile(File file, String string) write String To File OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); try { out.write(string.getBytes()); } finally { out.close(); |
File | writeStringToFile(File file, String string, String encoding) write String To File FileOutputStream out = new FileOutputStream(file); PrintStream p = new PrintStream(out, true, encoding); p.print(string); p.flush(); p.close(); out.close(); return file; |
void | writeStringToFile(File file, String stringToWrite) write String To File createNewFile(file); try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { writer.write(stringToWrite); |
void | writeStringToFile(File file, String text) write String To File System.out.println("Writing: " + file); File parentFile = file.getParentFile(); if (parentFile != null && !parentFile.exists()) { parentFile.mkdirs(); if (text == null) { throw new IllegalArgumentException("Text is null"); BufferedWriter out = new BufferedWriter(new FileWriter(file)); try { out.write(text); } catch (IOException e) { throw e; } finally { out.close(); |
void | writeStringToFile(File file, String text) Writes a string into a file. PrintStream out = new PrintStream(file);
out.print(text);
out.close();
|