在劫

吾生也有涯,而知也无涯 。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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

}

posted on 2018-07-08 02:33  长嘴大耳怪  阅读(51)  评论(0编辑  收藏  举报