Here you can find the source of copyFileBytes(String srcFileName, String tarFileName)
public static boolean copyFileBytes(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 copyFileBytes(String srcFileName, String tarFileName) { BufferedInputStream inBuff = null; BufferedOutputStream outBuff = null; try {/* ww w . j av a 2 s . c o m*/ inBuff = new BufferedInputStream(new FileInputStream(srcFileName)); outBuff = new BufferedOutputStream(new FileOutputStream(tarFileName)); 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; } }