Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
31
Task/Input-loop/Java/input-loop-2.java
Normal file
31
Task/Input-loop/Java/input-loop-2.java
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
|
||||
public class InputLoop {
|
||||
public static void main(String args[]) {
|
||||
// To read from stdin:
|
||||
Reader reader = new InputStreamReader(System.in);
|
||||
|
||||
/*
|
||||
Or, to read from a file:
|
||||
Reader reader = new FileReader(filename);
|
||||
|
||||
Or, to read from a network stream:
|
||||
Reader reader = new InputStreamReader(socket.getInputStream());
|
||||
*/
|
||||
|
||||
try {
|
||||
BufferedReader inp = new BufferedReader(reader);
|
||||
while(inp.ready()) {
|
||||
int input = inp.read(); // Use in.readLine() for line-by-line
|
||||
|
||||
// Process the input here. For example, you can print it out.
|
||||
System.out.println(input);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// There was an input error.
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue