org.jscience.physics.nuclear.kinematics
Class SimpleTokenReader

java.lang.Object
  extended by org.jscience.physics.nuclear.kinematics.SimpleTokenReader

public class SimpleTokenReader
extends java.lang.Object

Reads in values from a text file separated by whitespace (spaces, tabs, carriage returns & linefeeds). Everything after the # sign on any line is ignored as a comment. Anything between quotation marks (" "), is read in as a single string.


Constructor Summary
SimpleTokenReader(java.io.File f)
          Create an instance for reading in the file f.
 
Method Summary
 void close()
          One may call this to close the underlying file.
 double readDouble()
          Reads an double from the file, if the next token is a number.
 int readInteger()
          Reads an integer from the file, if the next token is a number.
 java.lang.String readString()
          Reads a string from the file, either a single word or the entire between two quotation marks (" ").
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleTokenReader

public SimpleTokenReader(java.io.File f)
                  throws java.io.IOException
Create an instance for reading in the file f.

Parameters:
f - text file to read from
Throws:
java.io.IOException - if something goes wrong opening the file
Method Detail

readInteger

public int readInteger()
                throws java.io.IOException
Reads an integer from the file, if the next token is a number. Floating point numbers are cast to integer.

Returns:
integer value
Throws:
java.io.IOException - if the next token is not a number

readDouble

public double readDouble()
                  throws java.io.IOException
Reads an double from the file, if the next token is a number.

Returns:
floating point value
Throws:
java.io.IOException - if the next token is not a number

readString

public java.lang.String readString()
                            throws java.io.IOException
Reads a string from the file, either a single word or the entire between two quotation marks (" ").

Returns:
the next token, if it's a String
Throws:
java.io.IOException - if the next token is not a String

close

public void close()
           throws java.io.IOException
One may call this to close the underlying file.

Throws:
java.io.IOException - if there's a problem closing the file