码迷,mamicode.com
首页 > 编程语言 > 详细

java SequenceInputStream

时间:2014-05-03 16:24:39      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:java   sequenceinputstream   

SequenceInputStream 能将两个输入流合并到一起

个别函数说明

bubuko.com,布布扣

上代码

import java.io.*;

public class SequenceDemo
{
	public static void main(String[] args)
	{
		try 
		{
			FileOutputStream out1=new FileOutputStream(new File("F:\\workspace\\JavaPrj\\test1.txt"));
			String str=new String("This is the first file!");
			out1.write(str.getBytes());
			out1.close();
			FileOutputStream out2=new FileOutputStream(new File("F:\\workspace\\JavaPrj\\test2.txt"));
			str="This is the second file!";
			out2.write(str.getBytes());
			out2.close();
			
			FileInputStream in1=new FileInputStream(new File("F:\\workspace\\JavaPrj\\test1.txt"));
			FileInputStream in2=new FileInputStream(new File("F:\\workspace\\JavaPrj\\test2.txt"));
			SequenceInputStream in=new SequenceInputStream(in1,in2);
			FileOutputStream out=new FileOutputStream(new File("F:\\workspace\\JavaPrj\\test12.txt"));
			int bt;
			while((bt=in.read())!=-1)
			{
				out.write(bt);
			}
			
			in1.close();
			in2.close();
			in.close();
			out.close();
		} 
		catch (FileNotFoundException e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		catch (IOException e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
bubuko.com,布布扣

java SequenceInputStream,布布扣,bubuko.com

java SequenceInputStream

标签:java   sequenceinputstream   

原文地址:http://blog.csdn.net/cjc211322/article/details/24907465

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!