Click or drag to resize
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.

Inheritance Hierarchy
SystemObject
  Algs4NetTextInput

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public sealed class TextInput

The TextInput type exposes the following members.

Constructors
  NameDescription
Public methodTextInput
Connect to the console for reading
Public methodTextInput(String)
Open a file for reading. Exceptions associated with the file open operation may be thrown
Top
Properties
  NameDescription
Public propertyIsEmpty
Check if there is no more input from the character stream
Top
Methods
  NameDescription
Public methodClose
Closes the input stream
Public methodHasNextBool
Checks if there is a bool value (1, 0, true or false) from the input stream
Public methodHasNextChar
Check if there is a char from the coming stream
Public methodHasNextDouble
Check if there is a double token from the coming stream
Public methodHasNextInt
Check if there is an integer token from the coming stream
Public methodHasNextLine
Check if there is a line, which is essentially a sequence of any characters
Public methodHasNextString
Checks if there is a space-delimited string from the stream
Public methodStatic memberMainTest
Demo test for the TextInput data type. The test shows the methods' behavior and how to use them.
Public methodReadAll
Read all characters from the steam into a string
Public methodReadAllDoubles
Reads all doubles from the input stream as an array of doubles
Public methodReadAllInts
Reads all integers from the input stream as an array of integers
Public methodReadAllStrings
Reads all space-delimited strings from the input stream as an array of strings
Public methodReadBool
Reads a bool value (1, 0, true or false, case-insensitive) from the input stream
Public methodReadChar
Reads a char from the stream
Public methodReadDouble
Reads a double from the stream
Public methodReadInt
Reads an integer from the stream
Public methodReadLine
Read a whole new line, discarding unprocessed strings in the previous line
Public methodReadString
Reads a space-delimited string from the stream
Top
Remarks
For additional documentation, see Section 1.5 of Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.
See Also