title: Why is my open and save feature using javafx not working?
body: <p>I am creating a 'save' to a specific file and an 'open' from the specific file. The save feature was working but since I have implemented the 'open' feature it has now stopped working. When the open feature is run I am printing it's contents to the console but at the moment the below error is shown in the console and only the first item of the array list is shown in the console. The 'open' and 'save' features are right at the bottom of my code but just before my two classes 'Record' and 'Getrecord' which are used for the 'save' and 'open' functions. I am very confused and not sure how to proceed as I don't know whats wrong.</p>
  
  <p>How the code appears:</p>
  
  <pre><code>miOpen.setOnAction(new EventHandler&lt;ActionEvent&gt;(){
                  @Override
                  public void handle(ActionEvent arg0) {
  
                  FileInputStream fis=null;
                  try{
                      fis = new FileInputStream("testsave.txt");
                  }
                  catch (FileNotFoundException e){
                      e.printStackTrace();
                  }
  
                  System.out.println("TEST OPEN B4");
  
  
  
  
  
                      String openstring = new String();
  
  
                      BufferedReader bwo = new BufferedReader(new InputStreamReader(fis));
                      try {
                          while( (openstring=bwo.readLine()) != null) {
  
                              String [] g = openstring.split(",");
                              System.out.println("TEST OPEN");
                              System.out.println(openstring);
  
                              getrecordsarray.add(new Getrecord(g[0], Double.parseDouble(g[1]), Double.parseDouble(g[2]), Double.parseDouble(g[3]), Double.parseDouble(g[4]), Double.parseDouble(g[5]), Double.parseDouble(g[6]), Double.parseDouble(g[7])));
                          }
                      } catch (NumberFormatException e) {
  
                          e.printStackTrace();
                      } catch (IOException e) {
  
                          e.printStackTrace();
                      }
  
                      try {
                          fis.close();
                      } catch (IOException e1) {
  
                          e1.printStackTrace();
                      }
  
  
  
                  }});
  
  miSave.setOnAction(new EventHandler&lt;ActionEvent&gt;(){
  
                  @Override
                  public void handle(ActionEvent arg0) {
                      fileChooser.setTitle("testsave1.txt");
                       try (BufferedWriter bw = new BufferedWriter(new FileWriter("testsave1.txt", true))) {
                              for(Record r : records)
                              bw.write(r.name + "," + r.age + "," + r.gender + "," + r.ethnicity + "," + r.answerA + "," + r.answerB + "," + r.answerC + "," + count);
                              bw.newLine();
                          } catch (IOException e) {
                              e.printStackTrace();
  
                          }
  
  
                       System.out.println("SAVED");
  
                       if (autoreturn==1){
  
                           System.out.println("saved fade");
                           FadeTransition ft = new FadeTransition(Duration.millis(3000), savemsg1);
                           ft.setFromValue(0);
                           ft.setToValue(1);
  
  
  
                           ft.play();
  
                           FadeTransition ft2 = new FadeTransition(Duration.millis(3000), savemsgl1);
                           ft2.setFromValue(0);
                           ft2.setToValue(1);
  
  
  
                           ft2.play();
  
  
  
                       }  
  
                  }});
  
  
          }
  
  void saveFile(File save)
  {
  FileOutputStream fos=null;
  try{
      fos = new FileOutputStream(save);
  }
  catch (FileNotFoundException e){
      e.printStackTrace();
  }
  
  
  
  
  
  try{
      fos.close();
  } catch (IOException e){ e.printStackTrace();
  }
  }
  
  
  
                  }
  </code></pre>
  
  <p>This error is thrown in the console when the 'open' button is run:</p>
  
  <pre><code>Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: 1
      at SurveyApp$10.handle(SurveyApp.java:1181)
      at SurveyApp$10.handle(SurveyApp.java:1)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
      at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
      at javafx.event.Event.fireEvent(Event.java:198)
      at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
      at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1405)
      at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.lambda$createChildren$343(ContextMenuContent.java:1358)
      at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
      at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
      at javafx.event.Event.fireEvent(Event.java:198)
      at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
      at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
      at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
      at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:352)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$355(GlassViewEventHandler.java:388)
      at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:387)
      at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
      at com.sun.glass.ui.View.notifyMouse(View.java:937)
  </code></pre>