zoukankan      html  css  js  c++  java
  • JAVA_字符流类

    package com.kk.review;

    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;

    public class CharStream {
    /*
    * Reader
    BufferedReader
    LineNumberReader
    CharArrayReader
    FilterReader
    PushbackReader
    InputStreamReader //实现字节流转化为字符流
    FileReader
    PipedReader
    StringReader

    Writer
    BufferedWriter
    CharArrayWriter
    FilterWriter
    OutputStreamWriter//实现字节流转化为字符流
    FileWriter
    PipedWriter
    PrintWriter
    StringWriter
    */
    public static void main(String[] args) {
    try {
    FileInputStream file=new FileInputStream("1.txt");//字节流
    InputStreamReader isr=new InputStreamReader(file);//将字节流转为字符流
    BufferedReader br=new BufferedReader(isr);//可以缓冲的字符流类
    System.out.println(br.readLine());
    file.close();

    FileOutputStream fos=new FileOutputStream("1.txt"); //字节流
    OutputStreamWriter osw=new OutputStreamWriter(fos);//将字符流转为字节流
    BufferedWriter bw=new BufferedWriter(osw);//带缓冲的字符流类
    bw.write("哈哈");
    fos.close();

    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
  • 相关阅读:
    BSGS
    [AT1252] IOIOI カード占い
    [十二省联考2019]春节十二响
    [CF912E] Prime Gift
    CDQ分治
    [CF747F] Igor and Interesting Numbers
    [十二省联考2019]异或粽子
    51Nod 2128 前缀异或
    51Nod 3212 数字变位
    HDU 1106 排序
  • 原文地址:https://www.cnblogs.com/BigIdiot/p/2282376.html
Copyright © 2011-2022 走看看