Class BusReader

java.lang.Object
  |
  +--BusReader

public class BusReader
extends java.lang.Object

This class reads lines of text from an input stream reader and interprets them as bus events.


Constructor Summary
BusReader(java.lang.String fn)
          Create a new BusReader object with which to read from a file.
BusReader(java.lang.String host, int port)
          Create a new BusReader object with which to read a network port.
 
Method Summary
 void close()
          Close the stream.
 hw7.TransitBusEvent getNextTransitBusEvent()
          Read one line from the input stream, decode it, construct a new TransitBusEvent, and return that to the caller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BusReader

public BusReader(java.lang.String host,
                 int port)
          throws java.io.IOException
Create a new BusReader object with which to read a network port.

Parameters:
host - the name of the host to read.
port - the number of the port to read

BusReader

public BusReader(java.lang.String fn)
          throws java.io.IOException
Create a new BusReader object with which to read from a file.

Method Detail

getNextTransitBusEvent

public hw7.TransitBusEvent getNextTransitBusEvent()
Read one line from the input stream, decode it, construct a new TransitBusEvent, and return that to the caller. Skip lines that are empty (0 characters) or that are blank (all whitespace). Return null at end of stream (end of file).

Returns:
a TransitBusEvent containing the information that was supplied in the bus event description line. Return null if that's what we get from the readLine().

close

public void close()
           throws java.io.IOException
Close the stream.

java.io.IOException