[java]代码库
import java.io.*;
/*
* SequenceStream.java
*
* Created on 2006年8月23日, 上午10:55
*
* 顺序输入流
*
* java.io包中提供了SequenceInputStream类,用于将多个输入流顺序连接起来,
* 使它们看起来就像一个较长的流。
*/
public class SequenceStream {
public static void main(String[] args) {
FileInputStream fileStream1, fileStream2;
try {
String allStr;
fileStream1 = new FileInputStream("d:\\mydir\\secondFile.txt");
fileStream2 = new FileInputStream("d:\\mydir\\thirdFile.txt");
SequenceInputStream seqStream = new SequenceInputStream(
fileStream1, fileStream2);
BufferedInputStream bufObj = new BufferedInputStream(seqStream);
byte[] bufByte = new byte[1024];
while (bufObj.read(bufByte, 0, 1024) != -1) {
String tempStr = new String(bufByte);
System.out.println(tempStr);
}
} catch (FileNotFoundException e) {
System.out.println("File not found or no permission.");
} catch (IOException e) {
System.out.println("error:" + e);
}
}
}