• Java中的IO操作 RWByCharStream


    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.io.UnsupportedEncodingException;
    
    
    public class RWByCharStream {
    
        public static void main(String[] args) {
            try {
                
                
                //File file = new File("java.txt");
                FileInputStream fis = new FileInputStream("java.txt");
                FileOutputStream fos = new FileOutputStream("java_new.txt");
                InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
                OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
                char input[] = new char[100];
                int l = 0;
                while ((l = isr.read(input)) != -1) {
                    //String inputString = new String(input,0,l);
                    osw.write(input,0,l);
                }
                isr.close();
                fis.close();
                osw.close();
                fos.close();
                System.out.println("done");
                
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            
        }
    
    }
  • 相关阅读:
    week8
    2020中国大学生程序设计竞赛(CCPC)-网络选拔赛 题解
    卷积形式dp的多项式求逆做法
    多项式乘法逆(review)
    LaTex学习
    BZOJ 2653 middle
    BZOJ3207 花神的嘲讽计划Ⅰ
    BZOJ1901 Zju2112 Dynamic Rankings
    POJ2104 K-th Number
    平衡树总结专题
  • 原文地址:https://www.cnblogs.com/xiaoruilin/p/16610815.html
Copyright © 2020-2023  润新知