Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Input-loop/Java/input-loop-1.java
Normal file
25
Task/Input-loop/Java/input-loop-1.java
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import java.io.InputStream;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class InputLoop {
|
||||
public static void main(String args[]) {
|
||||
// To read from stdin:
|
||||
InputStream source = System.in;
|
||||
|
||||
/*
|
||||
Or, to read from a file:
|
||||
InputStream source = new FileInputStream(filename);
|
||||
|
||||
Or, to read from a network stream:
|
||||
InputStream source = socket.getInputStream();
|
||||
*/
|
||||
|
||||
Scanner in = new Scanner(source);
|
||||
while(in.hasNext()){
|
||||
String input = in.next(); // Use in.nextLine() for line-by-line reading
|
||||
|
||||
// Process the input here. For example, you could print it out:
|
||||
System.out.println(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue