import structure5.*; import com.opencsv.CSVReader; import java.io.FileReader; import java.io.FileNotFoundException; import java.io.IOException; public class BookStats { public static void readBooks(String path, Set books) { CSVReader reader = null; try { reader = new CSVReader(new FileReader(path)); } catch (FileNotFoundException e) { System.err.println("File not found: '" + path + "'"); System.exit(1); } String[] row; try { while ((row = reader.readNext()) != null) { String isbn = row[5]; String authors = row[7]; String title = row[10]; Book b = new Book(isbn, authors, title); books.add(b); } } catch (IOException e) { System.err.println("Trouble reading file!"); System.exit(1); } } public static void readBooksWithTime(String path, Set books) { final long startTime = System.currentTimeMillis(); readBooks(path, books); final long endTime = System.currentTimeMillis(); System.out.println("Read " + books.size() + " records in " + (endTime - startTime) + "ms."); } public static void main(String[] args) { if (args.length != 1) { System.out.println("Usage: java BookStats "); } Set books = new SetList<>(); readBooksWithTime(args[0], books); Set booksh = new SetHashtable<>(); readBooksWithTime(args[0], booksh); } }