Here you can find the source of appendFileBytes(String srcFileName, String tarFileName)
public static boolean appendFileBytes(String srcFileName, String tarFileName)
//package com.java2s; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static boolean appendFileBytes(String srcFileName, String tarFileName) { BufferedInputStream inBuff = null; BufferedOutputStream outBuff = null; try {/*from w w w. j ava2 s . c o m*/ inBuff = new BufferedInputStream(new FileInputStream(srcFileName)); outBuff = new BufferedOutputStream(new FileOutputStream(tarFileName, true)); byte[] b = new byte[1024 * 5]; int len; while ((len = inBuff.read(b)) != -1) { outBuff.write(b, 0, len); } outBuff.flush(); } catch (IOException e) { e.printStackTrace(); return false; } finally { try { if (inBuff != null) { inBuff.close(); } if (outBuff != null) { outBuff.close(); } } catch (IOException e) { e.printStackTrace(); return false; } } return true; } }