public static <T>void writeArray(ObjectOutput out,T[] arr) throws IOException {
  int len=arr == null ? 0 : arr.length;
  out.writeInt(len);
  if (arr != null && arr.length > 0)   for (  T t : arr)   out.writeObject(t);
}

public static < T > void writeArray ( ObjectOutput out , T [ ] arr ) throws IOException { int len = arr == null ? 0 : arr . length ; out . writeInt ( len ) ; if ( arr != null && arr . length > 0 ) for ( T t : arr ) out . writeObject ( t ) ; }
writes array to output stream .
