Class NumberStream

java.lang.Object
au.edu.unsw.cse.NumberStream

public class NumberStream
extends java.lang.Object
This class provides a convenient way to read numbers from a text file
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected java.io.StreamTokenizer st  
  • Constructor Summary

    Constructors
    Constructor Description
    NumberStream​(java.io.InputStream is)
    Creates a NumberStream that parses the specified input stream.
    NumberStream​(java.io.Reader r)
    Creates a NumberStream that parses the specified character stream.
  • Method Summary

    Modifier and Type Method Description
    double next()
    return the next double from the stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • st

      protected java.io.StreamTokenizer st
  • Constructor Details

    • NumberStream

      public NumberStream​(java.io.InputStream is)
      Creates a NumberStream that parses the specified input stream.
      Parameters:
      is - - an input stream.
    • NumberStream

      public NumberStream​(java.io.Reader r)
      Creates a NumberStream that parses the specified character stream.
  • Method Details

    • next

      public double next() throws java.io.IOException
      return the next double from the stream. Return Double.NaN if end of file has been reached. Note: you must use Double.isNaN() to test if a double is NaN
      Throws:
      java.io.IOException