eos.util
Class In

java.lang.Object
  extended by eos.util.In

public class In
extends java.lang.Object

Input. This class provides methods for reading strings and numbers from standard input, file input, URL, and socket.

The Locale used is: language = English, country = US. This is consistent with the formatting conventions with Java floating-point literals, command-line arguments (via Double.parseDouble()) and standard output (via System.out.print()). It ensures that standard input works the number formatting used in the textbook.

For additional documentation, see Section 3.1 of Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.


Constructor Summary
In()
          Create an input stream for standard input.
In(java.io.File file)
          Create an input stream from a file.
In(java.net.Socket socket)
          Create an input stream from a socket.
In(java.lang.String s)
          Create an input stream from a filename or web page name.
In(java.net.URL url)
          Create an input stream from a URL.
 
Method Summary
 void close()
          Close the input stream.
 boolean exists()
          Does the input stream exist?
 boolean hasNextLine()
          Does the input stream have a next line?
 boolean isEmpty()
          Is the input stream empty?
static void main(java.lang.String[] args)
          Test client.
 java.lang.String readAll()
          Read and return the remainder of the input as a string.
 boolean readBoolean()
          Return the next boolean from the input stream, allowing "true" or "1" for true and "false" or "0" for false.
 byte readByte()
          Return the next byte from the input stream.
 char readChar()
          Read and return the next character.
 double readDouble()
          Return the next double from the input stream.
 double readFloat()
          Return the next float from the input stream.
 int readInt()
          Return the next int from the input stream.
 java.lang.String readLine()
          Read and return the next line.
 long readLong()
          Return the next long from the input stream.
 java.lang.String readString()
          Return the next string from the input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

In

public In()
Create an input stream for standard input.


In

public In(java.net.Socket socket)
Create an input stream from a socket.


In

public In(java.net.URL url)
Create an input stream from a URL.


In

public In(java.io.File file)
Create an input stream from a file.


In

public In(java.lang.String s)
Create an input stream from a filename or web page name.

Method Detail

exists

public boolean exists()
Does the input stream exist?


isEmpty

public boolean isEmpty()
Is the input stream empty?


hasNextLine

public boolean hasNextLine()
Does the input stream have a next line?


readLine

public java.lang.String readLine()
Read and return the next line.


readChar

public char readChar()
Read and return the next character.


readAll

public java.lang.String readAll()
Read and return the remainder of the input as a string.


readString

public java.lang.String readString()
Return the next string from the input stream.


readInt

public int readInt()
Return the next int from the input stream.


readDouble

public double readDouble()
Return the next double from the input stream.


readFloat

public double readFloat()
Return the next float from the input stream.


readLong

public long readLong()
Return the next long from the input stream.


readByte

public byte readByte()
Return the next byte from the input stream.


readBoolean

public boolean readBoolean()
Return the next boolean from the input stream, allowing "true" or "1" for true and "false" or "0" for false.


close

public void close()
Close the input stream.


main

public static void main(java.lang.String[] args)
Test client.