List of utility methods to do Write String to File
void | writeFile(String fileName, String output) Write a String to a file File file = openFile(fileName); if (file == null) { throw new FileNotFoundException(fileName); Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF8")); try { out.write(output); out.flush(); ... |
void | writeFile(String filename, String s) write File File f = new File(filename);
writeFile(f, s);
|
void | writeFile(String fileName, String source) write File FileWriter fos = new FileWriter(fileName); for (int i = 0; i < source.length(); i++) { fos.write(source.charAt(i)); fos.close(); return; |
void | writeFile(String filename, String str) Writes strto filename, overwriting it if it's already there. FileWriter out = new FileWriter(filename);
out.write(str, 0, str.length());
out.close();
|
void | writeFile(String filename, String string) Writes the specified string to the file with the specified name. writeFile(new File(filename), string);
|
File | writeFile(String filename, String text) write File FileOutputStream out = new FileOutputStream(filename); out.write(text.getBytes("UTF-8")); out.close(); return new File(filename); |
void | writeFile(String filename, String text) Write a text file. File file = new File(filename); if (null != file.getParentFile()) { file.getParentFile().mkdirs(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); String[] lines = text.split("#"); for (String line : lines) { writer.write(line); ... |
void | writeFile(String filename, String text) write File try { FileWriter fstream = new FileWriter(filename); BufferedWriter out = new BufferedWriter(fstream); out.write(text); out.close(); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); |
void | writeFile(String fileName, String text) write File FileWriter fw = new FileWriter(fileName, true); try { fw.write(text, 0, text.length()); } catch (IOException ioe) { throw new IOException("Write text to " + fileName + " fail!"); } finally { fw.close(); |
void | writeFile(String filename, String text, boolean create) Write a text file FileWriter fw = null; PrintWriter pw = null; if (create) { createDirectoriesForFile(filename); try { fw = new FileWriter(filename); pw = new PrintWriter(fw); ... |