public void mergeFile(String destPath) throws IOException {
// 创建源
File dest = new File(destPath);
// 选择流
BufferedOutputStream bos = null;// 输出流
try {
bos = new BufferedOutputStream(new FileOutputStream(dest,true));//追加
BufferedInputStream bis = null;
for (int i = 0; i < this.blockPath.size(); i++) {
bis = new BufferedInputStream(new FileInputStream(new File(this.blockPath.get(i))));
// 缓冲区
byte[] flush = new byte[1024];
int len = 0;
while (-1 != (len = bis.read(flush))) {
bos.write(flush, i, len);
}
bos.flush();
bis.close();
}
} catch (IOException e) {
e.printStackTrace();
}finally{
bos.close();
}
|