这个问题困惑了很久了,java 怎么才能从键盘读入数据啊,三个方面,main(String args[])
io流 , 和 swing 的  请高手指教
  最好写个例子,多谢了   

解决方案 »

  1.   

    public class ConsoleRead {
        public static void main(String[] args) {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            boolean inputOK;
            do {
                inputOK = true;
                System.out.print("Please Input you Numbers: ");
                String s = "";
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    System.out.println("IO ERROR");
                }
                String[] as = s.split(" ");
                if (s.compareToIgnoreCase("q") == 0) break;
                int[] ai = new int[as.length];
                try {
                    for (int i = 0; i < as.length; i++) {
                        ai[i] = Integer.parseInt(as[i]);
                    }
                } catch (Exception e) {
                    inputOK = false;
                }
            } while (!inputOK);
        }
    }
      

  2.   

    5.0中有一个Java.util.Scanner类,可以用于读入命令行下的数据,至于Swing方面的数据,一般都是用
    componet.getText()获得输入的文本。