System Input

In order to read in data from the user via the keyboard we make use of the system in class called System.in. We can not simply use the System.in class though as we need to allow the user to enter the data the want to send before the program makes use of it. As a result we have to use to other Java classes called the InputStreamReader and BufferedReader to read in keyboard input.

These classes are in the set of Java classes called java.io and therefore need to be imported at the top of any Java program that makes use of them.

import java.io.*;

We can then make use of the classes to read in data from the keyboard.

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input = br.readLine();


One comment on “System Input
  1. Randal says:

    I see a lot of interesting content on your blog.

    You have to spend a lot of time writing, i know how to save you
    a lot of work, there is a tool that creates unique, google friendly articles in couple
    of seconds, just type in google – laranita’s free content source

Leave a Reply

Your email address will not be published. Required fields are marked *

*