黑马程序员技术交流社区
标题:
读取键盘录入的数据并打印在控制台上
[打印本页]
作者:
王冀仁
时间:
2015-12-21 20:50
标题:
读取键盘录入的数据并打印在控制台上
import java.io.IOException;
02. import java.io.InputStream;
03.
04. public class ReadKey{
05. public static void main(String[] args) throws IOException {
06. readKey();
07. }
08.
09. public static void readKey() throws IOException {
10. InputStream in = System.in;
11.
12. int ch = in.read();// 阻塞式方法
13. System.out.println(ch);
14.
15 ch = in.read(); // 阻塞式方法
16. System.out.println(ch);
17.
18. ch = in.read(); // 阻塞式方法
19. System.out.println(ch);
20.
21. in.close();
22. }
23. }
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2