Java 2 Platform
v1.3

edu.umich.visualsoar.util
Class ReaderUtils

java.lang.Object
  |
  +--edu.umich.visualsoar.util.ReaderUtils

public class ReaderUtils
extends java.lang.Object

These are some utilities that I wrote to ease the reading in of files


Constructor Summary
private ReaderUtils()
           
 
Method Summary
static void copy(java.io.Writer w, java.io.Reader r)
          This function takes all data from a reader, and writes it to a writer a byte at a time
static float getFloat(java.io.Reader r)
          This gets a float out of the reader
static int getInteger(java.io.Reader r)
          This gets an Integer out of the reader
static java.lang.String getLine(java.io.Reader r)
          This gets a line out of the reader
static java.lang.String getWord(java.io.Reader r)
          a word is defined as non-whitespace characters terminated by a whitespace character
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReaderUtils

private ReaderUtils()
Method Detail

getWord

public static java.lang.String getWord(java.io.Reader r)
                                throws java.io.IOException
a word is defined as non-whitespace characters terminated by a whitespace character

Parameters:
r - the reader from which the user wants the word extracted
Returns:
a string that is a word as defined above
Throws:
java.io.IOException - represents something went wrong reading the stream

getInteger

public static int getInteger(java.io.Reader r)
                      throws java.io.IOException,
                             java.lang.NumberFormatException
This gets an Integer out of the reader

Parameters:
r - the reader from which the user wants the integer extracted
Returns:
an int that is the integer
Throws:
java.io.IOException - if there was an error reading from the reader
java.lang.NumberFormatException - if the integer in the reader isn't properly formatted

getFloat

public static float getFloat(java.io.Reader r)
                      throws java.io.IOException,
                             java.lang.NumberFormatException
This gets a float out of the reader

Parameters:
r - the reader from which the user wants the float extracted
Returns:
a float that is the number from the reader
Throws:
java.io.IOException - if there was an error reading from the reader
java.lang.NumberFormatException - if the float in the reader isn't properly formatted

getLine

public static java.lang.String getLine(java.io.Reader r)
                                throws java.io.IOException
This gets a line out of the reader

Parameters:
r - the reader from which the user
Throws:
java.io.IOException - if there was an error reading from the reader

copy

public static void copy(java.io.Writer w,
                        java.io.Reader r)
                 throws java.io.IOException
This function takes all data from a reader, and writes it to a writer a byte at a time

Parameters:
w - the destination
r - the source
Throws:
java.io.IOException - if there was an error reading from the source or writing to the destination

Java 2 Platform
v1.3