/**
* 通过vector容器使用sequenceInputStream
* @param destPath
*/
public void merge(String destPath){
File dest = new File(destPath);
BufferedOutputStream bos=null;//输出流
SequenceInputStream sis=null;
Vector<InputStream> vi = new Vector<InputStream>();
try {
for(int i=0;i<blockPath.size();i++){
vi.add(new BufferedInputStream(new FileInputStream(this.blockPath.get(i))));
}
bos = new BufferedOutputStream(new FileOutputStream(dest,true));//文件输出的追加
sis=new SequenceInputStream(vi.elements());//放入sequenceInputStream
byte[]flush =new byte[1024];
int len=0;
while(-1!=(len=sis.read(flush))){
bos.write(flush, 0, len);
}
bos.flush();
IOUtil.ioclose(sis);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
IOUtil.ioclose(bos);
}
}
通过Vector中放置inputstream使分割流统一放置在SequenceInputStream合并
最新推荐文章于 2021-03-01 16:58:17 发布