我正在通过此代码在 java 中捕获外部 .exe 文件的输出值
Process p = Runtime.getRuntime().exec("filepath\\myexefile.exe 5.53 46.46"); // 5.53 and 46.46 are two input orguments of exe file
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String s;
while ((s = stdInput.readLine()) != null) {
System.out.println(s); }
Double d = Double.valueOf(s);
System.out.println(d);
}
代码运行良好,它按预期显示输出 53.4429。但是,当我尝试将 53.4429 转换为 double 时,它会出现以下错误
Exception in thread "main" java.lang.NullPointerException
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1008)
at java.lang.Double.valueOf(Double.java:504)
知道为什么字符串不转换成双倍吗?提前致谢