我的报错信息为java.lang.NumberFormatException: For input string: ""SMX""
private void Encode() {
try {
BufferedReader reader = new BufferedReader(new FileReader("待加密坐标.csv"));
//reader.readLine();//第一行信息,为标题信息
String line = null;
BufferedWriter writer = new BufferedWriter(new FileWriter("已加密坐标.csv"));
while((line=reader.readLine())!=null){
String item[] = line.split(",");//CSV格式文件为逗号分隔符文件,这里根据逗号切分
String a = item[item.length-4];//提取首列
String x = item[item.length-3];//提取经度
String y = item[item.length-2];//提取纬度
String b = item[item.length-1];//提取末列
double X = Double.parseDouble(x);//将字符串转成双精度型
double Y = Double.parseDouble(y);
double[][] outXY = null;//声明局部变量并初始化
outXY[0] = encrypt(X,Y);
outXY[1] = encrypt(X,Y);
this.jTextArea2.append(a +","+ outXY[0]+","+ outXY[1] +","+ b + "," + "\r\n");
writer.write(a +","+ outXY[0]+","+ outXY[1] +","+ b + "," + "\r\n");
}
reader.close();
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
java exception
------解决方案--------------------
"SMX" 无法转成数字,
检查下你的数据文件,是否有不符合规范的数据
------解决方案--------------------
你试图吧
"SMX"转化成数据,所以报错。
String a = item[item.length-4];//提取首列
String x = item[item.length-3];//提取经度
String y = item[item.length-2];//提取纬度