jutil
Class IOUtils

java.lang.Object
  extended by jutil.IOUtils

public class IOUtils
extends java.lang.Object

Utilities for console and file I/O.


Field Summary
static java.io.PrintWriter stderr
          Represents standard error stream; default destination is console window unless redirected at the command line.
static java.io.BufferedReader stdin
          Represents standard input stream; default source is keyboard unless redirected at the command line.
static java.io.PrintWriter stdout
          Represents standard output stream; default destination is console window unless redirected at the command line.
 
Constructor Summary
IOUtils()
           
 
Method Summary
static void error(java.lang.String gripe)
          Prints an error message to stderr.
static java.io.BufferedReader makeReader(java.lang.String fname)
          A factory for turning file names into character input streams.
static java.io.PrintWriter makeWriter(java.lang.String fname)
          A factory for turning file names into character output streams.
static void print(java.io.PrintWriter writer, java.lang.String msg)
          Prints a message to a character output stream without a newline.
static void print(java.lang.String msg)
          Prints a message to stdout without a newline.
static void println(java.io.PrintWriter writer, java.lang.String msg)
          Prints a message to a character output stream with a newline.
static void println(java.lang.String msg)
          Prints a message to stdout with a newline.
static java.lang.String readLine()
          Reads a line from stdin without throwing an exception.
static java.lang.String readLine(java.io.BufferedReader reader)
          Reads a line from a reader without throwing an exception.
static void seriousError(java.lang.String gripe)
          Prints an error message to stdout then terminates the application.
static java.util.StringTokenizer tokenize(java.lang.String tokens)
          Parses a string into a sequence of tokens.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stdin

public static final java.io.BufferedReader stdin
Represents standard input stream; default source is keyboard unless redirected at the command line.


stdout

public static final java.io.PrintWriter stdout
Represents standard output stream; default destination is console window unless redirected at the command line.


stderr

public static final java.io.PrintWriter stderr
Represents standard error stream; default destination is console window unless redirected at the command line.

Constructor Detail

IOUtils

public IOUtils()
Method Detail

makeWriter

public static java.io.PrintWriter makeWriter(java.lang.String fname)
A factory for turning file names into character output streams.

Parameters:
fname - the name of the file to be written
Returns:
a character output stream

makeReader

public static java.io.BufferedReader makeReader(java.lang.String fname)
A factory for turning file names into character input streams.

Parameters:
fname - The name of the text file to be read.
Returns:
a character input stream

readLine

public static java.lang.String readLine(java.io.BufferedReader reader)
Reads a line from a reader without throwing an exception. A line is terminated by a newline char.

Parameters:
reader - a character input stream
Returns:
next line from the reader

readLine

public static java.lang.String readLine()
Reads a line from stdin without throwing an exception.

Returns:
next line from stdout

print

public static void print(java.io.PrintWriter writer,
                         java.lang.String msg)
Prints a message to a character output stream without a newline.

Parameters:
writer - a file output stream
msg - the message displayed

println

public static void println(java.io.PrintWriter writer,
                           java.lang.String msg)
Prints a message to a character output stream with a newline.

Parameters:
writer - a file output stream
msg - the message displayed

print

public static void print(java.lang.String msg)
Prints a message to stdout without a newline.

Parameters:
msg - the message displayed

println

public static void println(java.lang.String msg)
Prints a message to stdout with a newline.

Parameters:
msg - the message displayed

tokenize

public static java.util.StringTokenizer tokenize(java.lang.String tokens)
Parses a string into a sequence of tokens. A token is a string containing no white space.

Parameters:
tokens - the string to be parsed
Returns:
a sequence of tokens.

error

public static void error(java.lang.String gripe)
Prints an error message to stderr.

Parameters:
gripe - the error message

seriousError

public static void seriousError(java.lang.String gripe)
Prints an error message to stdout then terminates the application.

Parameters:
gripe - the error message