- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadChars.java
More file actions
Latest commit
23 lines (20 loc) · 620 Bytes
/
Copy pathReadChars.java
File metadata and controls
23 lines (20 loc) · 620 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Demonstrate reading characters from the console
importjava.io.*;
classReadChars {
publicstaticvoidmain(String[] args)
throwsIOException {
// catch the exception outside main() (meaning, never)
charc;
// wrap the byte stream to convert int to chars
// (completely redundant here...)
BufferedReaderaCReader
= newBufferedReader(newInputStreamReader(System.in));
// get characters from stdin
System.out.println("Enter some characters. Fullstop ends the input. Begin:");
do {
c = (char) aCReader.read();
System.out.print(c);
} while (c != '.');
System.out.println();
}
}