Package hsa
Class Stdin
- java.lang.Object
-
- hsa.Stdin
-
public class Stdin extends java.lang.ObjectThe Stdin class reads text from standard input. The class contains the same readLine method as BufferedReader and adds methods to read all the Java primitive data types with integrated error checking. It also handles EOF.This class is not meant to be instantiated.
Full documentation for the classes in the hsa package available at:
http://www.holtsoft.com/java/hsa_package.html
-
-
Field Summary
Fields Modifier and Type Field Description protected static TextInputFilein
-
Constructor Summary
Constructors Constructor Description Stdin()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose()Closes Stdin to further reading.static booleaneof()Returns whether there is an eof before the next token.static booleanreadBoolean()Read a boolean from standard input.static bytereadByte()Read an 8-bit integer (a "byte") from standard input.static charreadChar()Read a single character from standard input.static doublereadDouble()Read a double precision floating point number (a "double") from standard input.static floatreadFloat()Read a floating point number (a "float") from standard input.static intreadInt()Read a 32-bit integer (an "int") from standard input.static java.lang.StringreadLine()Read a full line of text from standard input.static longreadLong()Read a 64-bit integer (a "long") from standard input.static shortreadShort()Read a 16-bit integer (a "short") from standard input.static java.lang.StringreadString()Read a token from standard input.
-
-
-
Field Detail
-
in
protected static TextInputFile in
-
-
Method Detail
-
close
public static void close()
Closes Stdin to further reading.
-
eof
public static boolean eof()
Returns whether there is an eof before the next token.- Returns:
- Whether there is an eof before the next token
-
readBoolean
public static boolean readBoolean()
Read a boolean from standard input. The actual text entered must be either "true" or "false" although case is irrelvant.- Returns:
- The boolean value read from the file.
-
readByte
public static byte readByte()
Read an 8-bit integer (a "byte") from standard input. The actual text entered be a number from -128 to 127.- Returns:
- The byte value read from standard input.
-
readChar
public static char readChar()
Read a single character from standard input.- Returns:
- The character read from standard input.
-
readDouble
public static double readDouble()
Read a double precision floating point number (a "double") from standard input.- Returns:
- The double value read from standard input.
-
readFloat
public static float readFloat()
Read a floating point number (a "float") from standard input.- Returns:
- The float value read from standard input.
-
readInt
public static int readInt()
Read a 32-bit integer (an "int") from standard input. The actual text entered must be a number from -2147483648 to 2147483647.- Returns:
- The int value read from standard input.
-
readLine
public static java.lang.String readLine()
Read a full line of text from standard input.- Returns:
- The line of text read from standard input.
-
readLong
public static long readLong()
Read a 64-bit integer (a "long") from standard input.- Returns:
- The long value read from standard input.
-
readShort
public static short readShort()
Read a 16-bit integer (a "short") from standard input. The actual text entered must be a number from -32768 to 32767.- Returns:
- The short value read from standard input.
-
readString
public static java.lang.String readString()
Read a token from standard input.- Returns:
- The token read from standard input.
-
-