title: Saving to binary/serialization java
body: <p>I have to, quote on quote,</p>
  
  <blockquote>
    <p>1.Save accounts to a binary (serialized) file. 
    2.Load (recreate) accounts from a binary (serialized) file.</p>
  </blockquote>
  
  <p>So firstly, I was looking up examples of what exactly that is and I am lost, in same scenarios people mention xml, in my head I think it means like 01010011000 (binary), and when I look at other code it looks like a normal text file save.</p>
  
  <p>What exactly does he mean, and can someone post an example, or give me a site that better clarifies this? 
  Once I see what I actually need to do, I can implement it easily, I'm just confused on what exactly is being saved (data-wise) and how.</p>
  
  <p>*I already have an option to save via textfile (.txt) if I can just use some of that code for this binary part.</p>
  
  <p>Thanks!</p>
  
  <p>Here is what I have now, it's still not working I think.</p>
  
  <pre><code>import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.io.Serializable;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  public class SerializationMain implements Serializable {
  
      public static void saveSerialized(Object YourObject, String filePath) throws IOException {
          ObjectOutputStream outputStream = null;
          try {
              outputStream = new ObjectOutputStream(new FileOutputStream(filePath + ".dat"));
              outputStream.writeObject(YourObject);
          } catch (FileNotFoundException ex) {
              ex.printStackTrace();
          } catch (IOException ex) {
              ex.printStackTrace();
          } finally {
              try {
                  if (outputStream != null) {
                      outputStream.flush();
                      outputStream.close();
                  }
              } catch (IOException ex) {
                  ex.printStackTrace();
              }
          }
      }
  
      public static Object loadSerialized(String filePath, Object[][] data1) throws IOException {
          try {
              FileInputStream fileIn = new FileInputStream(filePath);
              ObjectInputStream in = new ObjectInputStream(fileIn);
              try {
                  data1 = (Object[][]) in.readObject();
              } catch (ClassNotFoundException ex) {
                  Logger.getLogger(SerializationMain.class.getName()).log(Level.SEVERE, null, ex);
              }
          } catch (FileNotFoundException ex) {
              ex.printStackTrace();
          } catch (IOException ex) {
              ex.printStackTrace();
          }
          System.out.println(data1.length);
          return data1;
      }
  }
  </code></pre>