Accepting Keyboard Input

First of all we need to know that in java for printing the line we use following command:

While we code the System then it is related with input and output and all the hardware conf.
Then the keyword out defines about the display of the line.
Now we need to input instead of output.
So just code by following ways:;

In this code the in defines the input of keyboard and the read means the input data is read by the java compiler.The InputStream class provides a primary function called read so this can read only a character at a time.
A sample class for input data:

In class SystemInExample:


public class SystemInExample {

public SystemInExample(){}

//a static method which perform input funtion throws IOException
public static String getInput()throws IOException{
StringBuffer strBuff = new StringBuffer();

//exception handler
char input = (char);
while(input != ‘n’){
input = (char);


//IO Exception handler
catch(IOException a){

//returns a string value
return strBuff.toString().trim();


In class InvokeInput
//importing java io package

public class InvokeInput {
public InvokeInput() { }

//a main method to invoke the input code
//this method throws and IOException
public static void main(String[] args)throws IOException{

System.out.print(“Please enter your Name: “);
String invoke = SystemInExample.getInput();
System.out.println(“Hello ” + invoke);






For any confusion please comment me:

Leave a Reply