Package hsa

Class Stdin


  • public class Stdin
    extends java.lang.Object
    The 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 TextInputFile in  
    • Constructor Summary

      Constructors 
      Constructor Description
      Stdin()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void close()
      Closes Stdin to further reading.
      static boolean eof()
      Returns whether there is an eof before the next token.
      static boolean readBoolean()
      Read a boolean from standard input.
      static byte readByte()
      Read an 8-bit integer (a "byte") from standard input.
      static char readChar()
      Read a single character from standard input.
      static double readDouble()
      Read a double precision floating point number (a "double") from standard input.
      static float readFloat()
      Read a floating point number (a "float") from standard input.
      static int readInt()
      Read a 32-bit integer (an "int") from standard input.
      static java.lang.String readLine()
      Read a full line of text from standard input.
      static long readLong()
      Read a 64-bit integer (a "long") from standard input.
      static short readShort()
      Read a 16-bit integer (a "short") from standard input.
      static java.lang.String readString()
      Read a token from standard input.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Stdin

        public Stdin()
    • 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.