我得到在Talend ETL工具NumberFormatException异常以下语句:获得NumberFormatException异常在Talend
Integer.parseInt("+2");
错误的详细信息:
Exception in component tJavaRow_3
java.lang.NumberFormatException: For input string: "+2"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
这是真的,没有任何问题,运行一个简单的代码在我的测试Java程序中。
public class Main {
public static void main(String[] args) {
String s = "+000000100";
System.out.println(String.valueOf(new Integer(s)));
}
}
其实从我的位置文件中获取该值和值可以是像0002或-0002(用符号为前缀的一些有效数字)。有一件事是确定输入中不会有任何小数。
在此先感谢。
其实我是从一个位置文件得到这个值,这个值可以是类似于+0002或-0002(一些有符号前缀的有效数字)。而这段代码在我的java测试程序中起作用。 'public class main { \t public static void main(String [] args)throws IOException {0} {0128} \t \t System.out.println(new Integer(s)); \t \t System.out.println(String.valueOf(new Integer(s))); \t \t System.out.println(s); \t} }' – Leejoy 2012-07-27 20:06:26
你确定约+0002吗?我只是试了一下。 NumberFormatException失败。你能发布你的测试代码吗? – kosa 2012-07-27 20:09:07