public static void serializePath(final ObjectOutput os,final PathIterator pi) throws IOException {
  os.writeObject(pi.getWindingRule());
  final List<java.io.Serializable> list=new ArrayList<java.io.Serializable>();
  while (!pi.isDone()) {
    final float[] array=new float[6];
    final int type=pi.currentSegment(array);
    list.add(type);
    list.add(array);
    pi.next();
  }
  os.writeObject(list);
}

public static void serializePath ( final ObjectOutput os , final PathIterator pi ) throws IOException { os . writeObject ( pi . getWindingRule ( ) ) ; final List < java . io . Serializable > list = new ArrayList < java . io . Serializable > ( ) ; while ( ! pi . isDone ( ) ) { final float [ ] array = new float [ 6 ] ; final int type = pi . currentSegment ( array ) ; list . add ( type ) ; list . add ( array ) ; pi . next ( ) ; } os . writeObject ( list ) ; }
method to serialize a path . this method will iterate through the iterator passed in , and write out the base components of the path to the objectoutput
