/** * Factory method * @param serializable any Object that implements Serializable * @param estimatedPayloadSize how many bytes is expected to be in the Serialized representation * @return a ByteArrayOutputStream with a Serialized object in it * @throws java.io.IOException if something goes wrong with the Serialization */ public static MemoryEfficientByteArrayOutputStream serialize(Serializable serializable, int estimatedPayloadSize) throws IOException { MemoryEfficientByteArrayOutputStream outstr = new MemoryEfficientByteArrayOutputStream(estimatedPayloadSize); ObjectOutputStream objstr = new ObjectOutputStream(outstr); objstr.writeObject(serializable); objstr.close(); return outstr; }
/** * Factory method. This method optimises memory by trying to make a better guess than the Java default * of 32 bytes by assuming the starting point for the serialized size will be what it was last time * this method was called. * @param serializable any Object that implements Serializable * @return a ByteArrayOutputStream with a Serialized object in it * @throws java.io.IOException if something goes wrong with the Serialization */ public static MemoryEfficientByteArrayOutputStream serialize(Serializable serializable) throws IOException { MemoryEfficientByteArrayOutputStream outstr = new MemoryEfficientByteArrayOutputStream(lastSize); ObjectOutputStream objstr = new ObjectOutputStream(outstr); objstr.writeObject(serializable); objstr.close(); lastSize = outstr.getBytes().length; return outstr; } }
/** * Factory method * @param serializable any Object that implements Serializable * @param estimatedPayloadSize how many bytes is expected to be in the Serialized representation * @return a ByteArrayOutputStream with a Serialized object in it * @throws java.io.IOException if something goes wrong with the Serialization */ public static MemoryEfficientByteArrayOutputStream serialize(Serializable serializable, int estimatedPayloadSize) throws IOException { MemoryEfficientByteArrayOutputStream outstr = new MemoryEfficientByteArrayOutputStream(estimatedPayloadSize); ObjectOutputStream objstr = new ObjectOutputStream(outstr); objstr.writeObject(serializable); objstr.close(); return outstr; }
/** * Factory method * @param serializable any Object that implements Serializable * @param estimatedPayloadSize how many bytes is expected to be in the Serialized representation * @return a ByteArrayOutputStream with a Serialized object in it * @throws java.io.IOException if something goes wrong with the Serialization */ public static MemoryEfficientByteArrayOutputStream serialize(Serializable serializable, int estimatedPayloadSize) throws IOException { MemoryEfficientByteArrayOutputStream outstr = new MemoryEfficientByteArrayOutputStream(estimatedPayloadSize); ObjectOutputStream objstr = new ObjectOutputStream(outstr); objstr.writeObject(serializable); objstr.close(); return outstr; }
/** * Factory method * @param serializable any Object that implements Serializable * @param estimatedPayloadSize how many bytes is expected to be in the Serialized representation * @return a ByteArrayOutputStream with a Serialized object in it * @throws java.io.IOException if something goes wrong with the Serialization */ public static MemoryEfficientByteArrayOutputStream serialize(Serializable serializable, int estimatedPayloadSize) throws IOException { MemoryEfficientByteArrayOutputStream outstr = new MemoryEfficientByteArrayOutputStream(estimatedPayloadSize); ObjectOutputStream objstr = new ObjectOutputStream(outstr); objstr.writeObject(serializable); objstr.close(); return outstr; }
/** * Factory method. This method optimises memory by trying to make a better guess than the Java default * of 32 bytes by assuming the starting point for the serialized size will be what it was last time * this method was called. * @param serializable any Object that implements Serializable * @return a ByteArrayOutputStream with a Serialized object in it * @throws java.io.IOException if something goes wrong with the Serialization */ public static MemoryEfficientByteArrayOutputStream serialize(Serializable serializable) throws IOException { MemoryEfficientByteArrayOutputStream outstr = new MemoryEfficientByteArrayOutputStream(lastSize); ObjectOutputStream objstr = new ObjectOutputStream(outstr); objstr.writeObject(serializable); objstr.close(); lastSize = outstr.getBytes().length; return outstr; } }
/** * Factory method. This method optimises memory by trying to make a better guess than the Java default * of 32 bytes by assuming the starting point for the serialized size will be what it was last time * this method was called. * @param serializable any Object that implements Serializable * @return a ByteArrayOutputStream with a Serialized object in it * @throws java.io.IOException if something goes wrong with the Serialization */ public static MemoryEfficientByteArrayOutputStream serialize(Serializable serializable) throws IOException { MemoryEfficientByteArrayOutputStream outstr = new MemoryEfficientByteArrayOutputStream(lastSize); ObjectOutputStream objstr = new ObjectOutputStream(outstr); objstr.writeObject(serializable); objstr.close(); lastSize = outstr.getBytes().length; return outstr; } }
/** * Factory method. This method optimises memory by trying to make a better guess than the Java default * of 32 bytes by assuming the starting point for the serialized size will be what it was last time * this method was called. * @param serializable any Object that implements Serializable * @return a ByteArrayOutputStream with a Serialized object in it * @throws java.io.IOException if something goes wrong with the Serialization */ public static MemoryEfficientByteArrayOutputStream serialize(Serializable serializable) throws IOException { MemoryEfficientByteArrayOutputStream outstr = new MemoryEfficientByteArrayOutputStream(lastSize); ObjectOutputStream objstr = new ObjectOutputStream(outstr); objstr.writeObject(serializable); objstr.close(); lastSize = outstr.getBytes().length; return outstr; } }