首页 > 代码库 > 【java】缓冲字符字节输入输出流:java.io.BufferedReader、java.io.BufferedWriter、java.io.BufferedInputStream、java.io.BufferedOutputStream

【java】缓冲字符字节输入输出流:java.io.BufferedReader、java.io.BufferedWriter、java.io.BufferedInputStream、java.io.BufferedOutputStream

BufferedReader最重要,因为有个方法public String readLine()

技术分享
 1 package System输入输出;
 2 
 3 import java.io.BufferedReader;
 4 import java.io.IOException;
 5 import java.io.InputStreamReader;
 6 
 7 public class Test {
 8     public static void main(String[] args) throws IOException {
 9        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
10        System.out.print("请输入数据:");
11        String str=br.readLine();
12        System.out.println(str);
13     }
14 }
不限制长度且无乱码输入

 

【java】缓冲字符字节输入输出流:java.io.BufferedReader、java.io.BufferedWriter、java.io.BufferedInputStream、java.io.BufferedOutputStream