IO_SequenceInputStream
Posted changzuidaerguai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IO_SequenceInputStream相关的知识,希望对你有一定的参考价值。
public class SequenceInputStreamJava {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String sPath1 = "d:" + File.separator + "javatest" + File.separator + "CollectionTest1.java";
String sPath2 = "d:" + File.separator + "javatest" + File.separator + "CollectionTest2.java";
Vector<FileInputStream> v = new Vector<>();
v.add(new FileInputStream(sPath1));
v.add(new FileInputStream(sPath2));
Enumeration<FileInputStream> e = v.elements();
SequenceInputStream si = new SequenceInputStream(e);
byte[] b = new byte[1024];
int result = 0;
//先读完sPath1文件,再读sPath2文件
while((result = si.read(b)) != -1) {
System.out.println(new String(b, 0, result));
}
si.close();
}
}
以上是关于IO_SequenceInputStream的主要内容,如果未能解决你的问题,请参考以下文章