A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 逝水大魔王 中级黑马   /  2016-5-22 22:23  /  498 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

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();
}
}

1 个回复

倒序浏览
默默的给你赞一个
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马