import java.io.FileInputStream;
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 CeShi {
public static void main(String[] args) throws IOException {
//创建输入流对象,关联文件
FileInputStream fis1 = new FileInputStream("E:\\测试类文件夹1\\Adele - Rolling In the Deep.mp3");
FileInputStream fis2 = new FileInputStream("E:\\测试类文件夹1\\Ariana GrandeIggy Azalea - Problem (Noodles & Devastator Remix) [mqms2].mp3");
FileInputStream fis3 = new FileInputStream("E:\\测试类文件夹1\\Backstreet Boys - As Long As You Love Me - 电台版.mp3");
//创建vector集合对象
Vector<InputStream> v = new Vector<>();
//添加流对象
v.add(fis1);
v.add(fis2);
v.add(fis3);
//获取枚举引用
Enumeration<InputStream> en = v.elements();
//传递给SequenceInputStream构造
SequenceInputStream sis = new SequenceInputStream(en);
FileOutputStream fos = new FileOutputStream("E:\\测试类文件夹1\\三合一音乐串烧.mp3");
byte[] arr = new byte[8*1024];
int b;
////用整合后的读
while ((b = sis.read(arr)) != -1) {
//写到指定文件中
fos.write(arr,0,b);
}
//关流
sis.close();
fos.close();
}
}
|
|