java.lang.Object
uk.ac.gda.excalibur.config.model.fit.StdIn

public final class StdIn extends Object
Standard input. This class provides methods for reading strings and numbers from standard input.

The Locale used is: language = English, country = US. This is consistent with the formatting conventions with Java floating-point literals, command-line arguments (via Double.parseDouble()) and standard output (via System.out.print()). It ensures that standard input works with the input files used in the textbook.

For additional documentation, see Section 1.5 of Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.

  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Does standard input have a next line?
    static boolean
    Is there only whitespace left on standard input?
    static void
    main(String[] args)
    Unit test
    static String
    Return rest of input from standard input
    static boolean
    Return next boolean from standard input, allowing "true" or "1" for true, and "false" or "0" for false
    static byte
    Return next byte from standard input
    static char
    Return next char from standard input
    static double
    Return next double from standard input
    static double[]
    Read rest of input as array of doubles
    static float
    Return next float from standard input
    static int
    Return next int from standard input
    static int[]
    Read rest of input as array of ints
    static String
    Return rest of line from standard input
    static long
    Return next long from standard input
    static short
    Return next short from standard input
    static String
    Return next string from standard input
    static String[]
    Read rest of input as array of strings

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isEmpty

      public static boolean isEmpty()
      Is there only whitespace left on standard input?
    • readString

      public static String readString()
      Return next string from standard input
    • readInt

      public static int readInt()
      Return next int from standard input
    • readDouble

      public static double readDouble()
      Return next double from standard input
    • readFloat

      public static float readFloat()
      Return next float from standard input
    • readShort

      public static short readShort()
      Return next short from standard input
    • readLong

      public static long readLong()
      Return next long from standard input
    • readByte

      public static byte readByte()
      Return next byte from standard input
    • readBoolean

      public static boolean readBoolean()
      Return next boolean from standard input, allowing "true" or "1" for true, and "false" or "0" for false
    • hasNextLine

      public static boolean hasNextLine()
      Does standard input have a next line?
    • readLine

      public static String readLine()
      Return rest of line from standard input
    • readChar

      public static char readChar()
      Return next char from standard input
    • readAll

      public static String readAll()
      Return rest of input from standard input
    • readInts

      public static int[] readInts()
      Read rest of input as array of ints
    • readDoubles

      public static double[] readDoubles()
      Read rest of input as array of doubles
    • readStrings

      public static String[] readStrings()
      Read rest of input as array of strings
    • main

      public static void main(String[] args)
      Unit test