Josh
Native console access wrapper for Java

com.yifanlu.Josh
Class JoshInput

java.lang.Object
  extended by com.yifanlu.Josh.JoshBuffer
      extended by com.yifanlu.Josh.JoshInput

public class JoshInput
extends JoshBuffer

Provides simplified access to the input buffer. Allow reading of user keyboard input in the console. Do not call this class directly, use Josh.in.

Since:
0.1
Version:
1.3, 05/29/10
Author:
Yifan Lu

Constructor Summary
JoshInput(ConsoleHandle handle)
          Creates a new input buffer for reading keyboard inputs.
 
Method Summary
 char readChar()
          Reads the first character from the console input buffer and removes it from the buffer.
 double readDouble()
          Reads the first character from the console input buffer and removes it from the buffer.
 int readInt()
          Reads the first character from the console input buffer and removes it from the buffer.
 java.lang.String readLine()
          Reads character input from the console input buffer and removes it from the buffer.
 
Methods inherited from class com.yifanlu.Josh.JoshBuffer
equals, getHandle, hashCode, setHandle
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JoshInput

public JoshInput(ConsoleHandle handle)
Creates a new input buffer for reading keyboard inputs. This class should, except in rare cases, never be called alone. Use Josh.in to access, as there is only one input buffer needed for a console. You must have the GENERIC_READ permission in the handle for the buffer to use the methods below.

Parameters:
handle - A memory location that this buffer represents. Usually the STD_INPUT_HANDLE from Josh.
Method Detail

readLine

public java.lang.String readLine()
Reads character input from the console input buffer and removes it from the buffer.

Returns:
The user's keyboard input.
See Also:
Windows' ReadConsole function

readChar

public char readChar()
Reads the first character from the console input buffer and removes it from the buffer.

Returns:
The user's keyboard input.
See Also:
Windows' ReadConsole function

readInt

public int readInt()
            throws java.lang.NumberFormatException
Reads the first character from the console input buffer and removes it from the buffer.

Returns:
The user's keyboard input.
Throws:
java.lang.NumberFormatException - If the input is not an integer.
See Also:
Windows' ReadConsole function

readDouble

public double readDouble()
                  throws java.lang.NumberFormatException
Reads the first character from the console input buffer and removes it from the buffer.

Returns:
The user's keyboard input.
Throws:
java.lang.NumberFormatException - If the input is not a double.
See Also:
Windows' ReadConsole function

Copyright © 2010 Yifan Lu