Code example for ObjectOutputStream

Methods: writeBoolean, writeFloat, writeObject

0
   */ 
  public void writeObject(final Object o, final ObjectOutputStream stream) throws IOException
  { 
    final GradientPaint gp = (GradientPaint) o;
    final Point2D point2D1 = gp.getPoint1();
    stream.writeFloat((float) point2D1.getX());
    stream.writeFloat((float) point2D1.getY());
    stream.writeObject(gp.getColor1());
    final Point2D point2D = gp.getPoint2();
    stream.writeFloat((float) point2D.getX());
    stream.writeFloat((float) point2D.getY());
    stream.writeObject(gp.getColor2());
    stream.writeBoolean(gp.isCyclic());
  } 
 
  /** 
   * Reads the object from the object input stream. 
   * 
   * @param stream the object input stream from where to read the serialized data. 
   * @return the generated object. 
   * @throws IOException            if reading the stream failed.