TextInput Class |
The TextInput class provides static methods for reading strings and numbers from standard input. It mimics the Java's Scanner class and adapt from the StdIn class from the textbook.
Namespace: Algs4Net
public sealed class TextInput
The TextInput type exposes the following members.
Name | Description | |
---|---|---|
TextInput |
Connect to the console for reading
| |
TextInput(String) |
Open a file for reading. Exceptions associated with the file open
operation may be thrown
|
Name | Description | |
---|---|---|
Close |
Closes the input stream
| |
HasNextBool |
Checks if there is a bool value (1, 0, true or false) from the input stream
| |
HasNextChar |
Check if there is a char from the coming stream
| |
HasNextDouble |
Check if there is a double token from the coming stream
| |
HasNextInt |
Check if there is an integer token from the coming stream
| |
HasNextLine |
Check if there is a line, which is essentially a sequence of any
characters
| |
HasNextString |
Checks if there is a space-delimited string from the stream
| |
MainTest |
Demo test for the TextInput data type. The test shows
the methods' behavior and how to use them.
| |
ReadAll |
Read all characters from the steam into a string
| |
ReadAllDoubles |
Reads all doubles from the input stream as an
array of doubles
| |
ReadAllInts |
Reads all integers from the input stream as an
array of integers
| |
ReadAllStrings |
Reads all space-delimited strings from the input stream as an
array of strings
| |
ReadBool |
Reads a bool value (1, 0, true or false, case-insensitive) from the input stream
| |
ReadChar |
Reads a char from the stream
| |
ReadDouble |
Reads a double from the stream
| |
ReadInt |
Reads an integer from the stream
| |
ReadLine |
Read a whole new line, discarding unprocessed strings in the previous line
| |
ReadString |
Reads a space-delimited string from the stream
|