//通过记住两个参数来初始化一个新创建的 SequenceInputStream ,这两个参数将按顺序读取,第一个是 s1 ,然后是 s2 ,以提供从该 SequenceInputStream读取的字节。
//SequenceInputStream(InputStream s1, InputStream s2)
//代码体现
public class SequenceInputStreamDemo {
public static void main(String[] args) throws IOException {
//封装两个FileInputStream对象
InputStream is=new FileInputStream("t.txt"); //多态
InputStream is1=new FileInputStream("t1.txt");
SequenceInputStream sis=new SequenceInputStream(is,is1);
BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("Copy1.txt"));
byte[] bys=new byte[1024];
int len;
while((len=sis.read(bys))!=-1){
bos.write(bys,0,len);
}
sis.close();
bos.close();
}
}
IO合拼流
最新推荐文章于 2023-06-13 19:53:42 发布