Files
GTSchoolShit/CS1322/final/Animals/IOHelper.java
2025-06-07 01:59:34 -04:00

99 lines
3.2 KiB
Java

/*====================================================================*/
/* D O N O T E D I T T H I S F I L E */
/*====================================================================*/
import java.io.*;
/**
* CS1312: IOHelper
* <PRE>
* IOHelper - a utility for reading input from the keyboard
*
* Revisions: 3.0 January 19, 2000
* Re-created class IOHelper
* Completetly Trashed old versions
* Removed backwards compatibility
*
* </PRE>
* @author <A HREF="mailto:cs1312@prism.gatech.edu">CS1312</A>
* @version Version 3.0, January 19, 2000
*/
public class IOHelper
{
/*=================================================================*/
/* C O N S T A N T S */
/*=================================================================*/
/**
* A Debug flag.
*/
public static final boolean bDEBUG = false;
/*=================================================================*/
/* C O N S T R U C T O R */
/*=================================================================*/
/**
* Declaring the default constructor private prevents anyone from
* making an instance of this class.
*/
private IOHelper()
{
System.err.println("IOHelper is not meant to be instantiated");
} // end of default constructor, IOHelper()
/*=================================================================*/
/* S T A T I C V A R I A B L E S */
/*=================================================================*/
/**
* Used by the BufferedReader to retrieve input.
* <BR><BR>
* @see #bReader bReader
*/
protected static InputStreamReader iStreamReader = new
InputStreamReader(System.in);
/**
* Retrieves input from the user using a wrapped InputStreamReader.
* <BR><BR>
* @see #iStreamReader iStreamReader
*/
protected static BufferedReader bReader = new
BufferedReader(iStreamReader);
/*=================================================================*/
/* S T A T I C M E T H O D S */
/*=================================================================*/
/**
* Retrieves input from the user using a BufferedReader
* <BR><BR>
* @return a String entered by the User
*/
public static final String readLine()
{
String strReturn = "";
try
{
strReturn = bReader.readLine();
} // end of try
catch (IOException ioe)
{
if (bDEBUG)
{
System.err.println("IOHelper: " + ioe.getMessage());
} // end of if
} // end of catch(IOException)
catch (NullPointerException npe)
{
/* This should NEVER happen */
System.err.println("IOHelper: " + npe.getMessage());
System.err.println("Please report this error to cs1312");
System.exit(1);
} // end of catch(NullPointerException)
return strReturn;
} // end of static method, readLine()
} // end of class IOHelper