List of utility methods to do Text File Save
void | serialize(final File folder, final String content, final String fileName) Serialize a content into a targeted file, checking that the parent directory exists. if (!folder.exists()) { folder.mkdirs(); final File output = new File(folder, fileName); FileWriter writer = null; try { writer = new FileWriter(output); writer.write(content); ... |
void | setText(File file, String text) set Text BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); bw.write(text, 0, text.length()); bw.flush(); bw.close(); |
void | writeFile(ArrayList write File FileWriter writer; try { writer = new FileWriter(dest_path); for (String str : lines) { writer.write(str); writer.close(); } catch (IOException e) { ... |
void | writeFile(Collection write File try { FileWriter fw = new FileWriter(new File(destFile)); BufferedWriter bw = new BufferedWriter(fw); for (String email : emailTree) { bw.write(email + "\n"); bw.flush(); bw.close(); ... |
void | writeFile(File destinationFile, String contents, String encoding) Writes given contents to destination file. OutputStream stream = new BufferedOutputStream(new FileOutputStream(destinationFile)); stream.write(contents.getBytes(encoding)); stream.close(); |
void | writeFile(File outputDirectory, String fileName, String source) write File File path = new File(outputDirectory.getAbsolutePath()); if (!path.exists()) { path.mkdirs(); File file = new File(path, fileName); if (!file.exists()) { file.createNewFile(); System.out.println("Generating: " + file.getAbsolutePath()); try (FileOutputStream fos = new FileOutputStream(file)) { fos.write(source.trim().getBytes()); } catch (FileNotFoundException e) { e.printStackTrace(); |
void | writeFile(File outputFile, ArrayList write File BufferedWriter out = null; try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "US-ASCII")); for (String line : sortedLines) { out.write(line.replaceAll("\\\\[\n\r]+", "\\\\" + lineSeparator)); out.write(lineSeparator); } finally { ... |
void | writeFile(File outputFile, String text) Writes the given text string into a file Writer writer; try { writer = new FileWriter(outputFile); } catch (IOException e) { throw new Exception("Couldn't create writer", e); try { writer.write(text); ... |
void | writeFile(File outputFolder, String fileName, String content) write File FileWriter outputFileReader = new FileWriter(new File(outputFolder, fileName)); BufferedWriter outputStream = new BufferedWriter(outputFileReader); outputStream.write(content); outputStream.close(); |
void | writeFile(File path, File file, String content) Write content to file using BufferedWriter.
try { if (!path.isDirectory()) { path.mkdir(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.write(content); writer.close(); } catch (IOException e) { ... |