The list of methods to do Serialize are organized into topic(s).
Object
serializeClone(final Object obj) Creates a clone by serializing object and deserializing byte stream.
ByteArrayOutputStream memOut = new ByteArrayOutputStream();
ObjectOutputStream objOut = new ObjectOutputStream(memOut);
objOut.writeObject(obj);
objOut.close();
ByteArrayInputStream src = new ByteArrayInputStream(memOut.toByteArray());
ObjectInputStream objIs = new ObjectInputStream(src);
return objIs.readObject();
void
serializeCookie(Object object, String filePath) serialize Cookie
OutputStream fos = null;
try {
fos = new FileOutputStream(filePath);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(object);
oos.flush();
fos.close();
oos.close();
...
Object
serializedCopy(Object obj) serialized Copy
try {
return deserialize(serialize(obj));
} catch (ClassNotFoundException e) {
throw new RuntimeException("this shouldn't happen");
T
serializedCopy(T object) serialized Copy
try {
ByteArrayOutputStream baout = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(baout);
out.writeObject(object);
out.flush();
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(baout.toByteArray()));
return (T) in.readObject();
} catch (Exception e) {
...
String
serializeExecutor(Object executor) Serializes an Executor for execution with TaskModeAwareExecutorFactory
if (executor instanceof Class) {
Class c = (Class) executor;
return "newinstance:" + c.getName();
} else {
ByteArrayOutputStream oo = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(oo);
os.writeUnshared(executor);
os.close();
...
Object
serializeFromString(final String pString) serialize From String
try {
final byte[] bytes = Base64.getDecoder().decode(pString);
final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
return ois.readObject();
} catch (final Exception pE) {
throw new RuntimeException(pE);
byte[]
serializeGZip(T obj) serialize G Zip
try {
return serializeGZipSafe(obj);
} catch (Exception e) {
throw new RuntimeException(e);
byte[]
serializeInt(int i) serialize Int
ByteArrayOutputStream bos = new ByteArrayOutputStream(4);
DataOutputStream dos = new DataOutputStream(bos);
try {
dos.writeInt(i);
} catch (IOException e) {
throw new RuntimeException(e);
return bos.toByteArray();
...
byte[]
serializeInt2MinLE(int value) Returns the minimum bytes needed for the given value to encoded it in little-endian format.
if (value < 0) {
throw new IllegalArgumentException("Negative input value");
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(4);
do {
byteStream.write(value & 0xFF);
value >>= 8;
} while (value != 0);
...