As part of a programming exercise I received the following:
"Simulator will receive orders from stdin in a simplified ascii format specified later in this document..."
"Input is received from stdin, and is in comma-separated ascii format. You may assume that the input will always be correctly formatted"
Example:
B,100322,5103,7500
This is all about the input mechnism. What i don't understand is the stdin them mention - is that the usual console input by the user, file input etc. ?
Usual console, yes.
In Java, the standard streams are referred to by
System.in
(for stdin ),System.out
(for stdout ), andSystem.err
(for stderr ).
See http://en.wikipedia.org/wiki/Standard_streams for further details
标准输入是控制台System.in
(如果未使用System.setIn(InputStream)
重新定义)。
I googled stdin
and the first match was http://en.wikipedia.org/wiki/Standard_streams which states
The three I/O connections are called standard input (stdin), standard output (stdout) and standard error (stderr)
So I googled stdin java
and the first match was http://introcs.cs.princeton.edu/java/stdlib/StdIn.java.html
Which has
// assume Unicode UTF-8 encoding
private static String charsetName = "UTF-8";
// assume language = English, country = US for consistency with System.out.
private static Locale usLocale = new Locale("en", "US");
// the scanner object
private static Scanner scanner = new Scanner(new BufferedInputStream(System.in), charsetName);
You can change the charsetName = "ASCII"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.