title: Output/Input of Java Files via GUI
body: <p>I have three classes libraryDB, libraryItems and libraryGUI. libraryDB() is essentially a hash map with the keys as book barcodes/ISBN's and the values are libraryItems, which consist of and therefore take two String parameters: Title and Author.</p>
  
  <p>I have a JFileChooser all set up in the GUI to save, but my save() and open() methods are giving problems. I want it set up so that when it is saved each libraryDB object has its own 3 lines (one each for Barcode, Title, Author, respectively). I tried loading them back in by reading each individual line in, here is the code I wrote for that:</p>
  
  <pre><code>//Suppose to construct a LibraryDB by reading one from a previously-saved file.
      public LibraryDB (File file) throws IOException {
          Scanner readFile = new Scanner(file);
          int barcode;
          String title;
          String author;
  
          while (readFile.hasNext()){
              barcode = Integer.parseInt(readFile.nextLine());
              title   = readFile.nextLine();
              author  = readFile.nextLine();
              LibraryItem authorTitleValues = new LibraryItem(title,author);
              this.libraryItems.put(barcode, authorTitleValues);
              }
      }
  //Trying to save to text file, where for each object n there are 3n lines.
      public void save(File file) throws IOException {
      PrintStream writer = new PrintStream(file);
      for (Iterator&lt;Integer&gt; localIterator = libraryItems.keySet().iterator(); 
      localIterator.hasNext();){ 
          int barcode = ((Integer)localIterator.next()).intValue();
          writer.println(barcode);
          writer.println((libraryItems.get(Integer.valueOf(barcode))).getTitle());
          writer.println((libraryItems.get(Integer.valueOf(barcode))).getAuthor());
          }
      }
  </code></pre>
  
  <p>Any help or insight that you can provide that will aid me in successfully being able to save/open would be much appreciated! Thanks!</p>
  
  <p>More explicity, whenever I save a libraryDB to a file I am unable to go back later and open up the file?</p>