import java.util.*; import java.io.*; public class Library { public static ArrayList library = new ArrayList();; public String fileName = "BooksForTheLibrary.txt"; public Library() { BufferedReader fileIn = null; try { fileIn = new BufferedReader (new FileReader(fileName)); String oneLine; LibraryBook book = new LibraryBook(); while ((oneLine = fileIn.readLine()) != null) { String[] bookAttribute = oneLine.split("/"); book.setTitle(bookAttribute[0]); book.setAuthor(bookAttribute[1]); book.setIsbn(bookAttribute[2]); library.add(book); System.out.println(bookAttribute[0]); } } catch (Exception e) { System.err.println("Problems with reading the file: " + e); } finally { if (fileIn != null) { try { fileIn.close(); } catch (IOException e) { System.err.println("Problems with closing the file: " + e); } } } } public static void showBooks() { LibraryBook book = new LibraryBook(); for (int i = 0; i < library.size(); i++) { book = (LibraryBook)library.get(i); System.out.println(book.getTitle() + book.getAuthor() + book.getIsbn()); } } public static void main(String[] args) { Library library = new Library(); showBooks(); } }