PDA

View Full Version : Java IO


sandie
01-21-2003, 11:20 AM
I would like to read data from the console in Java. I know that I need to use BufferedInputstream and/or DataInputStream but I need an example. Something like:-

Int valoe;
System.out.println("Please enter the percentage!");
then the the user enters/types: 60%

and then valoe = 60%.

I hope this makes sense!

Your help will be highly appreciated.

Thank you,

Spookster
01-21-2003, 05:00 PM
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String pct = null;

try{
pct = br.readLine();
}
catch(IOException e){
System.out.println("IO error has occurred");
System.exit(1);
}

System.out.println("You entered, " + pct);