String test = "15 kuruş";
Integer.parseInt工作正常.但是,当我从UTF-8文件中读取Scanner类时,它不起作用并给出异常
java.lang.NumberFormatException: For input string: “15”
注意:我将字符串拆分为“15”和“kuruş”,因此parseInt方法仅将“15”作为参数.
示例代码:
satir = satir.trim();//15 kuruş
StringTokenizer tokenizer = new StringTokenizer(satir," ");
System.out.println(tokenizer.countTokens());//2
String s = tokenizer.nextToken();
int deger = Integer.parseInt(s);//where the exception was throwed
最佳答案
原文链接:https://www.f2er.com/java/438263.html