title: How to serialize Java object - converting object as an InputStream
body: <p>If I write my code like this, it gives an error "File not found access denied ......"</p>
  
  <pre><code>public class ImplRegistration implements IRegistration {
   @Override
      public boolean newRegistration(Registration_BE reg_be) {
          FileOutputStream fos = new FileOutputStream("serial.ser");
          ObjectOutputStream oos = new ObjectOutputStream(fos);
          oos.writeObject(reg_be);
      }
  }
  </code></pre>
  
  <p>For security reasons, I changed the fourth line of the code to this:</p>
  
  <pre><code>FileOutputStream fos = new FileOutputStream("f://serial.ser");
  </code></pre>
  
  <p>But then it showed the exception <code>java.io.NotSerializableException: java.io.ByteArrayInputStream</code>.</p>
  
  <p>How can I serialize the object?</p>