package div;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.util.Enumeration;
import java.util.Vector;
public class merge {
private static void merge(Enumeration<InputStream> es) {
SequenceInputStream sis = new SequenceInputStream(es);
try {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("G://test//千锋Java教程:079.throw_throws与异常规则.mp4"));
byte[] bytes = new byte[1024];
int len = -1;
while((len=sis.read(bytes))!=-1) {
bos.write(bytes, 0, len);
bos.flush();
}
bos.close();
sis.close();
System.out.println("合并完成");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
InputStream in1 = new FileInputStream(new File("G://test//1千锋Java教程:079.throw_throws与异常规则.mp4"));
InputStream in2 = new FileInputStream(new File("G://test//2千锋Java教程:079.throw_throws与异常规则.mp4"));
InputStream in3 = new FileInputStream(new File("G://test//3千锋Java教程:079.throw_throws与异常规则.mp4"));
InputStream in4 = new FileInputStream(new File("G://test//4千锋Java教程:079.throw_throws与异常规则.mp4"));
InputStream in5 = new FileInputStream(new File("G://test//5千锋Java教程:079.throw_throws与异常规则.mp4"));
InputStream in6 = new FileInputStream(new File("G://test//6千锋Java教程:079.throw_throws与异常规则.mp4"));
Vector<InputStream> v = new Vector<InputStream>();
v.add(in1);
v.add(in2);
v.add(in3);
v.add(in4);
v.add(in5);
v.add(in6);
Enumeration<InputStream> es = v.elements();
merge(es);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}