I want a System class to read the books that have been written in a text file.
import java.io.BufferedReader;
import java.io.FileReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class System
{
private String FILENAME = "books.txt";
private static final int MAX_BOOKS = 10;
public void readBooks()
{
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(FILENAME));
String line = null;
int count=0;
while ((line = br.readLine()) != null && count < MAX_BOOKS) {
String[] values = line.split(",");
String ISBN = values[0];
String author = values[1];
String title = values[2];
String subject = values[3];
String inputDate = "04/04/2015";
SimpleDateFormat formatter = new SimpleDateFormat("d/M/yyyy");
Date date = null;
try {
date = formatter.parse(values[4]);
}
catch (ParseException exc)
{
System.out.println("A date format error occurred"); //***
}
Transaction bok = new Book(ISBN,author,title,subject,date);
books[count] = bok;
count++;
}
br.close();
numberOfBooks = count;
System.out.println("Books read from file successfully");
updateBalance();
}
catch (Exception ex) {
System.out.println("A file error occurred");
}
}
}
The error in the title refers to the System.out.println that I have highlighted. Why does this error show up and how can I fix it? Thanks in advance!