java 输入流代码_java顺序输入流

[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);

}

}

}

694748ed64b9390909c0d88230893790.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值