List of utility methods to do Text File Write
void | writeStringToFile(String path, String content) Write the given string content into a file with the specified path. writeStringToFile(new File(path), content);
|
void | writeStringToFile(String path, String contents) write String To File writeStringToFile(new File(path), contents, "UTF-8"); |
void | writeStringToFile(String s, File f) Writes a string to a file replacing the entire contents BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter(f)); bw.write(s); } finally { if (null != bw) { bw.close(); |
void | writeStringToFile(String s, File f) writes String as content of a java File object to disk. if (f == null) throw new IOException("null file"); FileOutputStream fos = new FileOutputStream(f); byte[] data = s.getBytes(); fos.write(data); fos.close(); |
void | writeStringToFile(String s, File f) write String To File if (f.exists()) { if (!f.delete()) { throw new RuntimeException("Cannot delete file " + f.getAbsolutePath()); FileWriter fw = null; try { if (!f.createNewFile()) { ... |
void | writeStringToFile(String s, File file) write String To File OutputStream out = null; try { out = new FileOutputStream(file); out.write(s.getBytes()); } finally { forceClosed(out); |
void | writeStringToFile(String s, String filename) writeStringToFile Write a string, which may include newline characters, line by line to the file specified by filename. String inputStr = s.trim(); if (inputStr.length() == 0) throw new IOException("Input string contains no printable characters."); BufferedReader br = new BufferedReader(new StringReader(inputStr)); BufferedWriter bw = new BufferedWriter(new FileWriter(filename)); try { String line; while ((line = br.readLine()) != null) { ... |
void | writeStringToFile(String s, String filePathname) write String To File makeParentDirectories(filePathname); BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(filePathname)); writer.write(s); } finally { if (writer != null) { writer.close(); ... |
boolean | writeStringToFile(String sdat, File f) write String To File String fnm = f.getName(); boolean ok = false; if (f != null) { boolean dogz = (fnm.endsWith(".gz")); try { OutputStream fos = new FileOutputStream(f); if (dogz) { fos = new GZIPOutputStream(fos); ... |
void | writeStringToFile(String str, File file) write String To File BufferedWriter writer = null; try { file.delete(); file.createNewFile(); writer = new BufferedWriter(new FileWriter(file)); writer.write(str); } catch (IOException e) { e.printStackTrace(); ... |