title: Serialize and Saving an ArrayList of double [] in Java
body: <p>I want to serialize and save an arraylist that contains a double [] arraylist in java. Here is my code. </p>
  
  <pre><code>FileOutputStream fileOutputStream = null; 
  ObjectOutputStream objectOutputStream = null; 
  FileInputStream fileInputStream = null; 
  ObjectInputStream objectInputStream = null; 
  
  public void writeArrayListToFile(ArrayList&lt;ArrayList&lt;double []&gt;&gt; arraylist, String outputFilePath){
  
      System.out.println("Start saving the file at  : " + outputFilePath);
  
      try {
          fileOutputStream = new FileOutputStream(outputFilePath , true);
          objectOutputStream = new ObjectOutputStream(objectOutputStream);
          objectOutputStream.writeObject(arraylist);
          System.out.println("Arraylist Saved Successfully...");
      } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }       
  }
  </code></pre>
  
  <p>But I get an error and following is the stack trace. </p>
  
  <p>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
      at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(Unknown Source)
      at java.io.ObjectOutputStream.(Unknown Source)
      at com.fyp.imur2.SaveArrayListToFile.writeArrayListToFile(SaveArrayListToFile.java:24)
      at com.fyp.imur2.JPanelJFreeChart.btnSaveGestureCollectionActionPerformed(JPanelJFreeChart.java:380)
      at com.fyp.imur2.JPanelJFreeChart.access$5(JPanelJFreeChart.java:375)
      at com.fyp.imur2.JPanelJFreeChart$6.actionPerformed(JPanelJFreeChart.java:166)
      at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
      at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
      at java.awt.Component.processMouseEvent(Unknown Source)
      at javax.swing.JComponent.processMouseEvent(Unknown Source)
      at java.awt.Component.processEvent(Unknown Source)
      at java.awt.Container.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Window.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
      at java.awt.EventQueue.access$200(Unknown Source)
      at java.awt.EventQueue$3.run(Unknown Source)
      at java.awt.EventQueue$3.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      at java.awt.EventQueue$4.run(Unknown Source)
      at java.awt.EventQueue$4.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)</p>
  
  <p>Can someone help me to solve this issue? Any help would be appreciated. Thanks in advance. </p>