zoukankan      html  css  js  c++  java
  • 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();
        }
    
    }
  • 相关阅读:
    命令行下的curl使用详解
    升级python版本(从2.4.3到2.6.5)
    vim设置
    php中curl模拟post提交多维数组
    vim折叠设置
    基础算法4——归并排序
    总线类型
    主板分类
    网卡 接口类型
    基础算法3——直接选择排序和堆排序
  • 原文地址:https://www.cnblogs.com/zhujialei123/p/9196585.html
Copyright © 2011-2022 走看看