List of utility methods to do Text File Save
void | writeFile(String str, File f) write File if (!f.exists()) { if (!f.getParentFile().exists() && !f.getParentFile().mkdirs()) throw new IOException("Unable to create dirs for file"); if (!f.createNewFile()) throw new IOException("Unable to create file"); FileWriter w = new FileWriter(f); w.write(str); ... |
void | writeFile(String str, String filename, boolean append) write File int length = str.length(); FileWriter out = new FileWriter(filename, append); out.write(str, 0, length); out.close(); |
void | writeFile(String string, File file) Writes the string specified to the file specified. try { ByteArrayInputStream bais = new ByteArrayInputStream(string.getBytes("UTF-8")); FileOutputStream fos = new FileOutputStream(file); copy(bais, fos); bais.close(); fos.flush(); fos.close(); } catch (Exception e) { ... |
boolean | writeFile(String string, File location, boolean forceASCII) write File if (!location.exists()) location.getParentFile().mkdirs(); try { if (location.exists()) location.delete(); location.createNewFile(); if (!forceASCII) { FileWriter fstream = new FileWriter(location); ... |
void | writeFile(String tailored, File f) write File FileWriter fw = new FileWriter(f, false);
fw.write(tailored);
fw.close();
|
boolean | writeFile(String targetPath, String filename, byte[] content) write File boolean ok = false; if (content != null && targetPath != null && targetPath.length() > 0 && filename != null && filename.length() > 0) { BufferedOutputStream bos = null; if (!targetPath.endsWith(File.separator)) { targetPath += File.separator; try { ... |
void | writeFile(String text, File file, boolean append) write File FileWriter fileWriter = new FileWriter(file, append);
fileWriter.write(text);
fileWriter.flush();
fileWriter.close();
|
void | writeFile(String text, File outf) write File File parent = outf.getParentFile(); if (parent != null) parent.mkdirs(); FileWriter f = new FileWriter(outf); PrintWriter pw = new PrintWriter(f); pw.println(text); pw.close(); f.close(); ... |
File | writeFile(String text, File target) Writes a text file. try { FileWriter fout = new FileWriter(target); fout.write(text); fout.close(); return target; } catch (Exception ex) { return null; ... |
void | writeFile(String txt, File fyl) Write a file. writeFile(txt.getBytes(), fyl); |