List of utility methods to do File Append
int | appendFile(String file, String text) append File return appendFile(file, text, null);
|
void | appendFile(String fileContents, File toFile) This method is to append the given contents into a file. RandomAccessFile raf = null; if (!toFile.exists()) { throw new FileNotFoundException(" The specified destination file does not exists "); } else { try { raf = new RandomAccessFile(toFile, "rw"); raf.skipBytes((int) raf.length()); raf.writeBytes(fileContents); ... |
boolean | appendFile(String fileName, byte[] data) append File FileOutputStream out = null; try { out = new FileOutputStream(fileName, true); out.write(data); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); ... |
void | appendFile(String fileName, String content) append File PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(fileName, true))); out.println(content); out.close(); |
void | appendFile(String filename, String text) append File FileWriter fw = null; try { fw = new FileWriter(filename, true); fw.append(text); } catch (IOException e) { e.printStackTrace(); } finally { try { ... |
void | appendFile(String filename, String text) append File PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(filename, true))); out.println(text); out.close(); |
void | appendFile(String fileName, StringBuffer sb) append File FileWriter fileWritter = new FileWriter(fileName, true); BufferedWriter bufferWritter = new BufferedWriter(fileWritter); bufferWritter.write(sb.toString()); bufferWritter.close(); |
boolean | appendFile(String fullName, String text) append File try { newFile(fullName); FileWriter out = new FileWriter(fullName, true); out.write(text); out.close(); } catch (Exception e) { System.out.println("error occur when creating file"); e.printStackTrace(); ... |
void | appendFile(String path, String content) append File File file = new File(path); if (!file.exists()) { file.createNewFile(); FileOutputStream outputStream = new FileOutputStream(file, true); outputStream.write(content.getBytes("utf-8")); outputStream.close(); |
void | appendFile(String path, String sb) append File try { FileWriter fstream = new FileWriter(path, true); try (BufferedWriter out = new BufferedWriter(fstream)) { out.write(sb); } catch (Exception e) { System.err.println("Error append file: "); System.err.println(path); ... |