Esempio n. 1
0
 // -----------------------------------------------------------------
 //  Returns a boolean read from standard input.
 // -----------------------------------------------------------------
 public static boolean readBoolean() {
   String token = getNextToken();
   boolean bool;
   try {
     if (token.toLowerCase().equals("true")) bool = true;
     else if (token.toLowerCase().equals("false")) bool = false;
     else {
       error("Error reading boolean data, false value returned.");
       bool = false;
     }
   } catch (Exception exception) {
     error("Error reading boolean data, false value returned.");
     bool = false;
   }
   return bool;
 }
Esempio n. 2
0
 // -----------------------------------------------------------------
 //  Returns a space-delimited substring (a word) read from
 //  standard input.
 // -----------------------------------------------------------------
 public static String readWord() {
   String token;
   try {
     token = getNextToken();
   } catch (Exception exception) {
     error("Error reading String data, null value returned.");
     token = null;
   }
   return token;
 }
Esempio n. 3
0
 // -----------------------------------------------------------------
 //  Returns a double read from standard input.
 // -----------------------------------------------------------------
 public static double readDouble() {
   String token = getNextToken();
   double value;
   try {
     value = (new Double(token)).doubleValue();
   } catch (Exception exception) {
     error("Error reading double data, NaN value returned.");
     value = Double.NaN;
   }
   return value;
 }
Esempio n. 4
0
 // -----------------------------------------------------------------
 //  Returns a float read from standard input.
 // -----------------------------------------------------------------
 public static float readFloat() {
   String token = getNextToken();
   float value;
   try {
     value = (new Float(token)).floatValue();
   } catch (Exception exception) {
     error("Error reading float data, NaN value returned.");
     value = Float.NaN;
   }
   return value;
 }
Esempio n. 5
0
 // -----------------------------------------------------------------
 //  Returns a long integer read from standard input.
 // -----------------------------------------------------------------
 public static long readLong() {
   String token = getNextToken();
   long value;
   try {
     value = Long.parseLong(token);
   } catch (Exception exception) {
     error("Error reading long data, MIN_VALUE value returned.");
     value = Long.MIN_VALUE;
   }
   return value;
 }
Esempio n. 6
0
 // -----------------------------------------------------------------
 //  Returns an integer read from standard input.
 // -----------------------------------------------------------------
 public static int readInt() {
   String token = getNextToken();
   int value;
   try {
     value = Integer.parseInt(token);
   } catch (Exception exception) {
     error("Error reading int data, MIN_VALUE value returned.");
     value = Integer.MIN_VALUE;
   }
   return value;
 }
Esempio n. 7
0
  // -----------------------------------------------------------------
  //  Returns a string read from standard input.
  // -----------------------------------------------------------------
  public static String readString() {
    String str;

    try {
      str = getNextToken(false);
      while (!endOfLine()) {
        str = str + getNextToken(false);
      }
    } catch (Exception exception) {
      error("Error reading String data, null value returned.");
      str = null;
    }
    return str;
  }
Esempio n. 8
0
  // -----------------------------------------------------------------
  //  Returns a character read from standard input.
  // -----------------------------------------------------------------
  public static char readChar() {
    String token = getNextToken(false);
    char value;
    try {
      if (token.length() > 1) {
        current_token = token.substring(1, token.length());
      } else current_token = null;

      value = token.charAt(0);
    } catch (Exception exception) {
      error("Error reading char data, MIN_VALUE value returned.");
      value = Character.MIN_VALUE;
    }

    return value;
  }