List of utility methods to do Text File Write
void | writeStringToFile(String string, File file) write String To File PrintWriter out = new PrintWriter(file);
out.print(string);
out.close();
|
void | writeStringToFile(String string, String fileName) write String To File File file = null; boolean fileCreated = false; if (fileName == null || string == null) { throw new IllegalArgumentException( "fileName or string passed in was NULL. Must have both these values."); file = new File(fileName); if (!file.exists()) { ... |
void | writeStringToFile(String string, String fileName, boolean append) write String To File BufferedWriter out = new BufferedWriter(new FileWriter(fileName, append)); out.write(string); out.close(); |
void | writeStringToFile(String string, String path) Writes specified string to specified file path. FileWriter fileWriter = null; try { File clusterFile = new File(path); fileWriter = new FileWriter(clusterFile); fileWriter.write(string); } finally { if (fileWriter != null) { fileWriter.close(); ... |
void | writeStringToFile(String stringContent, String fileName) * Output string to file ******************************************. PrintWriter printOut = new PrintWriter("c:\\temp\\" + fileName); printOut.println(stringContent); printOut.close(); |
void | writeStringToFile(String stringToBeWritten, String filePath) Creates, respectively overwrites the specified file with a given string BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(filePath)); bufferedWriter.write(stringToBeWritten); bufferedWriter.close(); |
File | writeStringToFile(String stringToWrite, String fileName) Writes a string (generated from running the previous method) on a plain text file. File file = new File(fileName); FileWriter writer = null; try { writer = new FileWriter(file); writer.write(stringToWrite); writer.close(); } catch (IOException ex) { ex.printStackTrace(); ... |
void | writeStringToFile(String text, File file) (Near-)atomically create or overwrite the specified file with the specified content, encoded as UTF-8. try { File tempFile = File.createTempFile(file.getName(), ".tmp", file.getParentFile()); FileOutputStream output = new FileOutputStream(tempFile, false); OutputStreamWriter writer = new OutputStreamWriter(output); writer.write(text); writer.flush(); writer.close(); if (file.exists()) ... |
void | writeStringToFile(String text, String file) write String To File OutputStream os = new FileOutputStream(file);
os.write(text.getBytes());
os.close();
|
void | writeStringToFile(String text, String filePath) Writes a string out to a file File outFile = new File(filePath);
writeStringToFile(text, outFile);
|