System.in            !!!

解决方案 »

  1.   

    System.in    
    System.in.read();
      

  2.   

    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String in = reader.readLine();
    String[] in2 = in.split(" ");
    int[] result = new int[in2.length];
    for (int i = 0; i < in2.length; i++) {
        if (in2[i] != null) {
            try {
                result[i] = Integer.parseInt(in2[1]);
            } catch (Exception e) {
            }
        }
    }将上面代码做成函数,每次需要调用就可以了
    cin太不安全,你要是达到上面这几行代码相同的安全效果用cin可有代码写呢...
      

  3.   

    String[] in2 = in.split(" ");
    换成
    String[] in2 = in.split(" +");
    更安全一点
    代码没测试,有什么不对的地方请担待...
      

  4.   

    其实我自己也有的.只是我想散分.并且看看还有什么简单的方法.
    import java.io.*;public class KeyBoardReader{

    private BufferedReader br;

    public KeyBoardReader(){
    br = new BufferedReader(new InputStreamReader(System.in));
    }

    public BufferedReader getReader(){
    return this.br;
    }

    public void setReader(BufferedReader br){
    this.br = br;
    }

    public double readdouble(){
    double value = 0.0;
    try{
    String s = br.readLine();
    System.out.println("s: " + s);
    value = Double.parseDouble(s);
    }
    catch(Exception e){
    System.out.println("Exception: " + e.getMessage());
    }
    return value;
    }

    public static void main(String[] args){
    KeyBoardReader input = new KeyBoardReader();
    System.out.println("please input double: ");
    double radio = input.readdouble();
    System.out.println("radio: " + radio);
    }

    }
      

  5.   

    想要简单的可以试试sdk1.5.0的printf
      

  6.   

    俺也开了个贴子在散分,也欢迎楼主朋友来接分啊。:)http://community.csdn.net/Expert/topic/3206/3206781.xml?temp=.7858545信誉值在一百以上的家伙似乎都是对csdn和社区作过重要贡献的那种,楼主只要够努力,我想也会成为那种家伙的,呵呵。。
      

  7.   

    System.in.read();
    byte aa[]=new byte[4];
    PrintStream ps=new PrintStream(System.out);
    ps.wirteTo(aa);
      

  8.   

    恭喜恭喜!可以用正则表达式判断,或者使用的时候捕获NumberFormatExceptoin!