首页 > 其他 > 详细

IO流(序列流)

时间:2018-06-18 23:03:18      阅读:230      评论:0      收藏:0      [点我收藏+]
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流(序列流)

原文:https://www.cnblogs.com/zhujialei123/p/9196585.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!