Class IO

java.lang.Object
  extended by IO

public final class IO
extends java.lang.Object

Utility class for basic IO functions.


Field Summary
static java.io.PrintStream stderr
          A PrintStream associated with stderr
static java.io.BufferedReader stdin
          A BufferedReader associated with the stdin stream
static java.io.PrintStream stdout
          A PrintStream associated with stdout
 
Method Summary
static boolean affirmative(java.lang.String yn)
          Tests if a string value begins with 'y' or 'Y'
static java.lang.String prompt(java.lang.String s)
          Gets prompted input as a string from the user via stdin
static int promptInt(java.lang.String s, int low, int high)
          Gets prompted input parsed as an int within the specified range from the user via stdin
static java.lang.String readFile(java.lang.String name)
          Reads an entire file into a single string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stdin

public static java.io.BufferedReader stdin
A BufferedReader associated with the stdin stream


stdout

public static java.io.PrintStream stdout
A PrintStream associated with stdout


stderr

public static java.io.PrintStream stderr
A PrintStream associated with stderr

Method Detail

affirmative

public static boolean affirmative(java.lang.String yn)
Tests if a string value begins with 'y' or 'Y'

Parameters:
yn - the string
Returns:
true if string represents "yes"

readFile

public static java.lang.String readFile(java.lang.String name)
Reads an entire file into a single string

Parameters:
name - The filename to read
Returns:
a single string with the entire contents of the file

prompt

public static java.lang.String prompt(java.lang.String s)
Gets prompted input as a string from the user via stdin

Parameters:
s - The prompt to display on stdout to request input
Returns:
The line of input from stdin as a string

promptInt

public static int promptInt(java.lang.String s,
                            int low,
                            int high)
Gets prompted input parsed as an int within the specified range from the user via stdin

Parameters:
s - The prompt to display on stdout to request input
low - The low value of the acceptable range of input
high - The high vaue of the range
Returns:
The int value parsed from the user input