美文网首页
2.3.8字符流

2.3.8字符流

作者: linhaoyou | 来源:发表于2017-07-12 20:10 被阅读0次
Paste_Image.png Paste_Image.png Paste_Image.png
import java.io.*;

public class MyReadFile {
    public static void main(String[] args){
        try {
            File f = new File("D:/work/test.txt");
            
            FileReader fr = new FileReader(f);
            
            System.out.println(fr.read());
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
}
Paste_Image.png Paste_Image.png
import java.io.*;

public class MyReadFile {
    public static void main(String[] args){
        try {
            File f = new File("D:/work/test.txt");
            
            FileReader fr = new FileReader(f);
            BufferedReader br = new BufferedReader(fr);
            
            System.out.println(br.readLine());
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
}
Paste_Image.png Paste_Image.png Paste_Image.png
import java.io.*;

public class MyReadFile {
    public static void main(String[] args){
        try {
            File f = new File("D:/work/test.txt");
            
            FileReader fr = new FileReader(f);
            BufferedReader br = new BufferedReader(fr);
            
            while (br.ready()) {
                System.out.println(br.readLine());
            }           
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
}
Paste_Image.png
import java.io.*;

public class MyReadFile {
    public static void main(String[] args){
        try {
            File inFile = new File("D:/work/test.txt");
            File outFile = new File("D:/test1.txt");
            
            FileReader fr = new FileReader(inFile);
            BufferedReader br = new BufferedReader(fr);
            
            FileWriter fw = new FileWriter(outFile);
            PrintWriter pw = new PrintWriter(fw);
            
            while (br.ready()) {
                pw.println(br.readLine());
            }
            
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
}
Paste_Image.png Paste_Image.png
import java.io.*;

public class MyReadFile {
    public static void main(String[] args){
        try {
            File inFile = new File("D:/work/test.txt");
            File outFile = new File("D:/test1.txt");
            
            FileReader fr = new FileReader(inFile);
            BufferedReader br = new BufferedReader(fr);
            
            FileWriter fw = new FileWriter(outFile);
            PrintWriter pw = new PrintWriter(fw);
            
            while (br.ready()) {
                pw.println(br.readLine());
            }
            
            pw.close();
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
}
Paste_Image.png Paste_Image.png

相关文章

  • 2.3.8字符流

  • Java基础笔记21

    21.01_IO流(字符流FileReader) 1.字符流是什么字符流是可以直接读写字符的IO流字符流读取字符,...

  • Java IO流之字符流

    ①IO流(字符流FileReader) 1.字符流是什么字符流是可以直接读写字符的IO流字符流读取字符, 就要先读...

  • IO(字符流)&字符流其他内容&递归

    day21(IO(字符流)&字符流其他内容&递归) 1_IO流(字符流FileReader) 1.字符流是什么字符...

  • day21-Java IO流(字符流/装饰设计模式)

    21.01_字符流FileReader 1.字符流是什么字符流是可以直接读写字符的IO流字符流读取字符, 就要先读...

  • Topic21(字符流)

    21.01 字符流FileReader 字符流是什么字符流是可以直接读写字符的IO流字符流读取字符,就要先读取到字...

  • I/O的学习之字符流

    I/O的学习之字符流 今天的学习内容 字符流FileReader 字符流FileWriter 字符流的拷贝 带缓冲...

  • 2020-06-30【字符流】

    字节缓冲流 字符流 编码表 字符流写数据的5中方式 字符流读取数据的2种方式 练习 字符缓冲流 IO流小结

  • Java基础笔记总结(14)-IO流(2)字符流 FileRea

    字符流是什么 字符流是可以读写字符的IO流 字符流读取字符,先要读取字节数据,然后转换为字符,需要把字符转换为字节...

  • IO Stream - 字符流

    字符流 字符流出现的原因1.字符流介绍:由于字节流操作中文不是特别方便,所以Java提供了字符流字符流 = 字节流...

网友评论

      本文标题:2.3.8字符流

      本文链接:https://www.haomeiwen.com/subject/zgebhxtx.html