Search
Categories
  ASP.NET
Visual C#
Visual Basic
.NET Framework
ADO.NET
AJAX
LINQ
Java
 
Tutorial Rating
 
4.4 out of 5


Total Votes: 21
         
1 2 3 4 5
 




Reading Console Input in Java

Author: Waqas Anwar - Posted Date: 06-April-2008 - Category: Java   
Bookmark and Share
Reading console input in simple java console applications is a very straight forward process. Java provides developers two predefined streams in the java.lang.System class to read and write data to and from standard input and output devices. System.out is a standard output stream which is Console by default and System.in is predefined input stream which is Keyboard by default. To read user input in a console window we connect system.in with other stream classes available in java.io package.
 
Following code example shows you how to read user input in console window in java.

import java.io.*;

public class ConsoleInput
{
      public static void main(String[] args) throws Exception
      {
            System.out.println("Enter Your Text: " );   
            InputStreamReader r = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(r); 
            String s = br.readLine(); 
            System.out.println(s);     
      }
}





RELATED TUTORIALS

  How to Read Text File in Java
  Writing Text Files in Java using FileWriter class
  How to Copy File in Java

LEAVE YOUR COMMENTS LEAVE YOUR COMMENTS
 Name (required)  
 Email (required
 Website


 

 


 
 
 

Categories

My Portfolio

Website Links


Copyright @ 2009 EzzyLearning.com