数据类型转换问题!!! str.toString() 不是合法数字亚 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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. 好像你读得是字节,把它有转换成了自符,所以你得到的字符串应该不是你输入的字符串! 用这个试试!byte[] bytesRead=new byte[2];String ch;try{ while(System.in.read(bytesRead)!=-1){ ch=new String(bytesRead); str.append(ch); }}没调试,不知行不行! j = Integer.parseInt(str.toString().trim()); 不知道你的变量str是定义为什么类型的数据,不过,好像是String,如果是String的话,你大可不必用str.toString(),直接使用就可以了 jimshen(jimshen) 你扛的芯比比别人都多,回答问题一针见血,另小弟(如果是男的话,以下同)万分佩服,我们交个朋友吧,如果我是女的话一定要嫁给你,二奶也乐意。20分全给你,快看你的钱包,请笑纳。 面试遇到一个简单的问题,高手指点一下! JAVA新手问题.. \n 换行问题 第一次在CSDN提问题,我刚刚学习Java.请大家多多指教! 谢谢!!! 高手,你在哪里,我需要您的帮助:关于I/O的问题 如何隐藏JTabbedPane的一个页签? swt开发包中dll的问题。 求一个数据库类! 跪谢!我作拉一个简单的想记事本样的程序可以运行,但有点问题请进来看看可以吗谢谢。。(有源程序,具体问题描述) 求救,关于jdbc的!在线! 在vaj4.0里用过JCE的大师们请进来帮帮小的吧 为什么我的prepareStatement中的setDate()老是报错呢?!
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.
好像你读得是字节,把它有转换成了自符,所以你得到的字符串应该不是你输入的字符串!
byte[] bytesRead=new byte[2];
String ch;
try{
while(System.in.read(bytesRead)!=-1){
ch=new String(bytesRead);
str.append(ch);
}
}
没调试,不知行不行!