nl.nikhef.slcshttps.util
Class ConsoleTools

java.lang.Object
  extended by nl.nikhef.slcshttps.util.ConsoleTools

public class ConsoleTools
extends Object

Static class providing tools for use with stdio/console.

Version:
0.1
Author:
Mischa Sallé

Constructor Summary
ConsoleTools()
           
 
Method Summary
static boolean getConfirm(String question)
          Confirmation from the user via console, returning true/false.
static char[] getPassword(String prompt)
          Provides a password prompt.
static String readLine()
          Reads and returns a line from the console (System.in).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsoleTools

public ConsoleTools()
Method Detail

readLine

public static String readLine()
                       throws IOException
Reads and returns a line from the console (System.in).

Returns:
the line read.
Throws:
IOException - upon read error

getPassword

public static char[] getPassword(String prompt)
                          throws IOException
Provides a password prompt. For JDK1.6 and onwards we do this with java.io.Console.readPassword(). For older versions we use PasswordReader.

Parameters:
prompt - String message printed before user input.
Returns:
char[] with the password.
Throws:
IOException - upon error.

getConfirm

public static boolean getConfirm(String question)
                          throws IOException
Confirmation from the user via console, returning true/false.

Parameters:
question - String asked before user input.
Returns:
boolean - true when user agrees.
Throws:
IOException - upon error.


nl.nikhef.slcshttps Mischa Sallé - msalle(AT)nikhef.nl