我试图从.CSV文件读取数据。我写了下面的代码,我需要读取3列数据。其中之一是被视为布尔值,以下是我在CSV中的数据。从Java中的.CSV文件读取
211假 53 12真正 50 21真正 1 0假
因此,基于在最后一列的布尔值在尝试应用在如环不同的动作。我是新来的Java环境可以有人帮助我实现。
while ((line = br.readLine()) != null) {
// use comma as separator
String[] separator = line.split(cvsSplitBy);
totalPapers = Integer.parseInt(separator[0]);
totalColors = Integer.parseInt(separator[1]);
if (total_papers[2] == "true"){
isDoublePrints = true;
}
isDoublePrints = Boolean.parseBoolean(total_papers[2]);
System.out.println(isDoublePrints);
if(isDoublePrints == true){
totalPapers = (int) (totalBW * 0.12);
totalColors = (int) (totalColors * 0.13);
}
else{
totalPapers = (int) (totalBW * 0.24);
totalColors = (int) (totalColors * 0.22);
}
}
} catch (IOException e) {
e.printStackTrace();
}
每当我运行这个程序时,编译器会得到其他的。即使我的CSV的最后一列有真正的值。
仍然收到同样的错误我的问题是PHP存在问题。因为它显示在错误日志中PHP注意:未定义索引: –
PHP注意:未定义索引:电子邮件 –
PHP注意:未定义索引:密码以及 –