str.toString() 不是合法数字亚

解决方案 »

  1.   

    try{
         while((ch=(char)System.in.read())!='\n')
         str.append(ch);
    }catch(java.io.IOException e){}abstract  int read() 
              Reads the next byte of data from the input stream. 
    好像你读得是字节,把它有转换成了自符,所以你得到的字符串应该不是你输入的字符串!
      

  2.   

    用这个试试!
    byte[] bytesRead=new byte[2];
    String ch;
    try{
         while(System.in.read(bytesRead)!=-1){
           ch=new String(bytesRead);
           str.append(ch);
         }
    }
    没调试,不知行不行!
      

  3.   

    j = Integer.parseInt(str.toString().trim());
      

  4.   

    不知道你的变量str是定义为什么类型的数据,不过,好像是String,如果是String的话,你大可不必用str.toString(),直接使用就可以了
      

  5.   

    jimshen(jimshen) 你扛的芯比比别人都多,回答问题一针见血,另小弟(如果是男的话,以下同)万分佩服,我们交个朋友吧,如果我是女的话一定要嫁给你,二奶也乐意。20分全给你,快看你的钱包,请笑纳。