-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboardTest.java
More file actions
43 lines (34 loc) · 892 Bytes
/
Copy pathKeyboardTest.java
File metadata and controls
43 lines (34 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package javaIO;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class KeyboardTest {
public static void main(String[] args) {
BufferedReader br = null;
try {
// 기반 스트림 (표준입력, stdin,System.in)
// 보조스트림1
InputStreamReader isr = new InputStreamReader(System.in, "UTF-8");
// 보조스트림2(char|char|char|......|\n -> "charcharchar")
br=new BufferedReader(isr);
//read
String line=null;
while((line=br.readLine())!=null)
{
if("exit".equals(line))break;
}
System.out.println(">>"+line);
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Error:" + e);
}finally {
try {
if(br!=null)
br.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}