我对AP计算机科学的一个项目工作,我们基本上是做一个图书馆,在那里你可以添加客户和书籍,借书给客户,等等,我们必须能够读取/写入CSV.我在使用这段代码时遇到了一些麻烦(这只是其中的一部分,而且我很确定其余部分是有效的,整个过程总共接近600行):
public void readForBook() {
try{
BufferedReader CSVFile = new BufferedReader(new FileReader("book.csv"));
String dataRow = CSVFile.readLine();
dataRow = CSVFile.readLine();
while (dataRow != null){
String[] dataArray = dataRow.split(", ");
int tbuid = Integer.parseInt(dataArray[0]);
String t_title = dataArray[1];
String tfirst = dataArray[2];
String tlast = dataArray[3];
String tdescription = dataArray[4];
String tisbn = dataArray[5];
String tdpurchase = dataArray[6];
String tcopyrightyear = dataArray[7];
double tcost = Double.parseDouble(dataArray[8]);
dataRow = CSVFile.readLine();
int crYear = Integer.parseInt(tcopyrightyear);
Book tempBook = new Book(tbuid, t_title, tfirst, tlast, tdescription, …Run Code Online (Sandbox Code Playgroud)