import java.io.*; public class Demo1 { public static void main(String args[]) { try{ InputStreamReader isr=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(isr); System.out.println("请输入一个数"); String str=br.readLine(); System.out.println(str); }catch(Exception e) { e.printStackTrace(); } } }
其中
InputStreamReader isr=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(isr);
可直接整合成
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));