package com.heima.ceshi;
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 test1 {
public static void main(String[] args) throws IOException {
FileInputStream file1 = new FileInputStream("周杰伦 - 安静.mp3"); //创建输入流对象,关联a.txt
FileInputStream file2 = new FileInputStream("周杰伦 - 飘移.mp3"); //创建输入流对象,关联b.txt
FileInputStream file3 = new FileInputStream("周杰伦 - 我不配.mp3"); //创建输入流对象,关联c.txt
Vector<InputStream> ve = new Vector<>();
ve.add(file1);
ve.add(file2);
ve.add(file3);
Enumeration<InputStream> en = ve.elements();
SequenceInputStream se = new SequenceInputStream(en);
FileOutputStream fos = new FileOutputStream("周董歌曲串烧.mp3");
int len;
byte[] arr = new byte[1000000];
while ((len = se.read(arr)) != -1) {
fos.write(arr,0,len);
}
fos.close();
se.close();
}
}
|
|