List of utility methods to do Text File Write
void | writeSet2File(Set write Set File if (set == null || filePath == null || set.isEmpty()) { return; File file = new File(filePath); if (!file.exists()) { if (log.isInfoEnabled()) { log.info("create file:" + file.getPath()); file.createNewFile(); BufferedWriter bw = new BufferedWriter(new FileWriter(file, true)); for (String str : set) { bw.write(str); bw.newLine(); bw.close(); |
void | writeString(String string, File file, boolean append) Simply executes #writeBytes writeBytes ( string.getBytes(), file, append ) .
Check.arg().notNull(string); writeBytes(string.getBytes(), file, append); |
void | writeStringToFile(String content, String fileName) Writes a string to a file. BufferedWriter fw = createBufferedUtf8Writer(fileName); fw.write(content); fw.flush(); fw.close(); |
void | writeStringToFile(String content, String fileName, boolean append) Writes a string to a file. BufferedWriter fw = createBufferedUtf8Writer(fileName, append); fw.write(content); fw.flush(); fw.close(); |
void | writeStringToFile(String string, File file) write String To File FileWriter fw = new FileWriter(file);
fw.append(string);
fw.close();
|
void | writeStringToFile(String stringToWrite, String filename) write String To File OutputStream os = new FileOutputStream(filename);
os.write(stringToWrite.getBytes());
os.close();
|
void | writeText(File file, String text) write Text writeText(file, text, null); |
void | writeText(File file, String text, String charsetName) write Text byte[] bytes = charsetName == null ? text.getBytes() : text
.getBytes(charsetName);
writeBytes(file, false, bytes);
|
void | writeTextFile(String path, String text) Writes the contents of a String to a file. FileWriter writer = new FileWriter(path, false);
writer.write(text);
writer.close();
|
File | writeTextFile(String string, String fileName) write text to a specified text file store in temporary path try { File file = new File(FileUtil.tmpdir + fileName + ".txt"); FileOutputStream fos = new FileOutputStream(file); OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); osw.write(string); osw.flush(); osw.close(); fos.close(); ... |