Scanner BufferedReader ( - . , . Scanner ). , , read() System.in Scanner.
public static void main(String[] args) {
Scanner s1 = new Scanner(System.in);
s1.hasNext();
Scanner s2 = new Scanner(System.in);
while(true){
System.out.println("Read line:: " + s2.nextLine());
}
}
Scanner:
1
2
3
4
:
:: e 1
:: 2
:: 3
:: 4
, . Scanner s1. 2 Scanner Stream.
, .
private static Scanner s;
public static void main(String[] args) {
s = new Scanner(System.in);
check(1);
}
static void check(int count) {
if (s.hasNextLine()) {
String ns = s.nextLine();
System.out.println(count + " " + ns);
count++;
check(count);
}
}
s.hasNextLine() s.hasNext(), .
s.hasNextLine()==true, true , s.hasNextLine() true.
EOF , Ctrl+Z Windows Ctrl+D Unix. , EOF, NetBeans.