Program to Read text entered by use in consoler using BufferedReader's readLine() method in java file IO



Read : Program to Read text entered by user in console using DataInputStream in java file IO







Program to Read text entered by use in consoler using BufferedReader's readLine() method in java file IO >





import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/** JavaMadeSoEasy.com */
public class ReadFromUsersInput {
   public static void main(String[] args) throws IOException {
         
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
          System.out.print("enter your name : ");
          //will wait for user to enter name
          String name = br.readLine(); // syntax for String
          System.out.println("Your name is : " + name);
          System.out.print("enter your age : ");
          //will wait for user to enter age
          int age = Integer.parseInt(br.readLine()); // syntax for int
          System.out.println("Your age is : " + age);
          br.close(); //close BufferedReader
   }
}
/*OUTPUT
enter your name : ankit
Your name is : ankit
enter your age : 30
Your age is : 30
*/


RELATED LINKS>

Program to Read text entered by user in console using DataInputStream in java file IO

Read text entered by use in consoler using BufferedReader's readLine() method in java file IO

Program to Read text entered by use in console using java.util.Scanner

Program to Read text entered by user in console till some special character (let's say @) in java


Program to Read text from file using FileInputStream and Try with resource provided in java 7


Must read for you :

No comments:

Post a Comment