public static <T extends Serializable>void write(File file,T object) throws IOException {
  try (ObjectOutputStream output=new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)))){
    output.writeObject(object);
  }
 }

public static < T extends Serializable > void write ( File file , T object ) throws IOException { try ( ObjectOutputStream output = new ObjectOutputStream ( new BufferedOutputStream ( new FileOutputStream ( file ) ) ) ) { output . writeObject ( object ) ; } }
writes the given object to the given file .
