Class TextInput

java.lang.Object
  |
  +--TextInput

public class TextInput
extends java.lang.Object

A TextInput object encapsulates a stream of text connected
to an actual input stream (InputStream or Reader).

Author:
Ken Slonneger

Constructor Summary
TextInput()
          Creates a TextInput object connected to the keyboard.
TextInput(java.io.InputStream is)
          Creates a TextInput object encapsulating an InputStream.
TextInput(java.io.Reader rd)
          Creates a TextInput object encapsulating a Reader.
 
Method Summary
 double readDouble()
          Reads one double from input stream.
 int readInt()
          Reads one int from input stream.
 java.lang.String readLine()
          Reads a line of text from input stream, consumming the end-of-line character(s).
 long readLong()
          Reads one long from input stream.
 java.lang.String readToken()
          Reads one token from input stream using whitespace as delimiter.
 java.lang.String readWord()
          Reads one English word from input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextInput

public TextInput()
Creates a TextInput object connected to the keyboard.

TextInput

public TextInput(java.io.InputStream is)
Creates a TextInput object encapsulating an InputStream.
Parameters:
is - InputStream from which bytes (ASCII characters) can be read.

TextInput

public TextInput(java.io.Reader rd)
Creates a TextInput object encapsulating a Reader.
Parameters:
rd - Reader from which Unicode characters can be read.
Method Detail

readLine

public java.lang.String readLine()
Reads a line of text from input stream, consumming the end-of-line character(s).
Returns:
One line of characters as a String without a linefeed.
Returns the value null when the end of the stream is reached.

readToken

public java.lang.String readToken()
Reads one token from input stream using whitespace as delimiter.
Returns:
A String consisting of the next non-whitespace token.
Returns an empty string when the end of the stream is reached.

readWord

public java.lang.String readWord()
Reads one English word from input stream.
Returns:
A String consisting of the next word made up letters and apostrophes.
Returns an empty string when the end of the stream is reached.

readInt

public int readInt()
Reads one int from input stream.
Returns:
An int value. Returns 0 if number is malformed.

readDouble

public double readDouble()
Reads one double from input stream.
Returns:
A double int value. Returns 0.0 if number is malformed.

readLong

public long readLong()
Reads one long from input stream.
Returns:
A long value. Returns 0L if number is malformed.