IO流(序列流)
Posted zhujialei123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IO流(序列流)相关的知识,希望对你有一定的参考价值。
package com.day17.IO; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.SequenceInputStream; public class OtherIO { public static void main(String[] args) throws IOException { fun(); FileInputStream fis1=new FileInputStream("a.txt"); FileInputStream fis2=new FileInputStream("b.txt"); SequenceInputStream sis=new SequenceInputStream(fis1,fis2); FileOutputStream fos=new FileOutputStream("c.txt"); int b; while((b=sis.read())!=-1) { fos.write(b); } sis.close(); fos.close(); } private static void fun() throws FileNotFoundException, IOException { FileInputStream fis1=new FileInputStream("a.txt"); //FileInputStream fis2=new FileInputStream("b.txt"); FileOutputStream fos=new FileOutputStream("c.txt"); int b1; while((b1=fis1.read())!=-1) { fos.write(b1); } fis1.close(); FileInputStream fis2=new FileInputStream("b.txt"); int b2; while((b2=fis2.read())!=-1) { fos.write(b2); } fis2.close(); fos.close(); } }
以上是关于IO流(序列流)的主要内容,如果未能解决你的问题,请参考以下文章
IO流相关知识(File,字节流,字符流,特殊操作流(标准输入流,标准输出流,对象序列化与反序列化,properties与IO流结合))相关知识总结