June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,9 +1,25 @@
import java.io.InputStream;
import java.util.Scanner;
...
Scanner in = new Scanner(System.in);//stdin
//new Scanner(new FileInputStream(filename)) for a file
//new Scanner(socket.getInputStream()) for a network stream
while(in.hasNext()){
String input = in.next(); //in.nextLine() for line-by-line
//process the input here
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);
}
}
}

View file

@ -1,16 +1,31 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
...
try{
BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));//stdin
//new BufferedReader(new FileReader(filename)) for a file
//new BufferedReader(new InputStreamReader(socket.getInputStream())) for a network stream
while(inp.ready()){
String input = inp.readLine();//line-by-line only
//in.read() for character-by-character
//process the input here
}
} catch (IOException e) {
//There was an input error
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.
}
}
}