使用java.io.BufferedReader和java.io.InputStreamReader类读取键盘输入并将其存储到局部变量中。
import java.io.*; /** 来 自 nowjava.com - 时代Java**/ public class Main { public static void main(String[] args){ BufferedReader readIn = new BufferedReader( new InputStreamReader(System.in)); String numberAsString = ""; long numberAsLong = 0; boolean numberIsValid = false; do { /* Ask the user for a number. */ System.out.println("Please enter a number: "); try { numberAsString = readIn.readLine(); System.out.println("You entered " + numberAsString); } catch (IOException ex){ System.out.println(ex); } /* 来自 *时 代 J a v a*/ /* Convert the number into binary form. */ try { numberAsLong = Long.parseLong(numberAsString); numberIsValid =