* 1.Scanner:
* 2.main()方法的形参;
* 3.System.in;
public static void main(String[] args) throws IOException {
InputStream in = System.in;
/*
* int n = in.read(); System.out.println("你输入的字节数:" + n);
* System.out.println("转换为字符:" + (char)n);
*/
// 想办法从控制台读取一行数据:
// 读取一行数据:BufferedReader
// 从字节流--->转换流--->字符流
/*
* InputStreamReader isr = new InputStreamReader(in); BufferedReader
* bufIn = new BufferedReader(isr);
*/
BufferedReader bufIn = new BufferedReader(
new InputStreamReader(System.in));
String row = bufIn.readLine();
System.out.println("你输入的内容是:" + row);
//将标准的输出流也封装为带缓冲的字符流
PrintStream ps = System.out;
BufferedWriter bufOut = new BufferedWriter(new OutputStreamWriter(ps));
bufOut.write("张学友");
bufOut.newLine();
bufOut.write("刘德华");
bufOut.newLine();
bufOut.close();
} |
|