List of utility methods to do File Append
void | appendFile(File src, File dst) append File copyOrAppend(src, dst, true); |
void | appendFile(File targetFile, String text) Appends the given String to the end of a file. BufferedWriter writer = new BufferedWriter(new FileWriter(targetFile)); writer.append(text); writer.flush(); writer.close(); |
void | appendFile(File targetFile, String toWrite) Opens a file (targetFile) and appends a String (toWrite) to it if (!targetFile.exists()) { if (!targetFile.createNewFile()) throw new Exception("File was not created!"); if (!targetFile.canWrite()) throw new Exception("No permission to write file!"); else { try { ... |
void | appendFile(final File srcFile, final File destFile) This method append the src file to dest file. InputStream in = null; in = new FileInputStream(srcFile); final FileOutputStream out = new FileOutputStream(destFile, true); final byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); if (in != null) { in.close(); if (out != null) { out.close(); |
void | appendFile(final String filename, final String content) append File FileOutputStream output = new FileOutputStream(filename, true); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output)); writer.write(content); writer.close(); output.close(); |
void | appendFile(final String name, final String s) Writes to the file with the given name writeFile(name, s, true); |
void | appendFile(OutputStream output, File source) append File InputStream input = null; try { input = new BufferedInputStream(new FileInputStream(source)); byte[] buf = new byte[1024]; int len; while ((len = input.read(buf)) > 0) { output.write(buf, 0, len); } finally { input.close(); |
void | appendFile(String content, File file) append File BufferedWriter writer = new BufferedWriter(new FileWriter(file, true)); writer.write(content); writer.newLine(); writer.close(); |
void | appendFile(String file, byte[]... data) append File try (FileOutputStream fos = new FileOutputStream(file, true)) { for (byte[] d : data) { fos.write(d); } catch (IOException ex) { |
void | appendFile(String file, String content) Append 'content' in 'dir'/'file' try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file, true)))) { out.println(content); out.close(); } catch (Exception e) { e.printStackTrace(); |