List of utility methods to do Serialize
void | serializeObjectToFile(Object obj, File f) serialize Object To File FileOutputStream fos = new FileOutputStream(f); try { BufferedOutputStream bos = new BufferedOutputStream(fos, 1024 * 128); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(obj); oos.close(); } finally { fos.close(); ... |
void | serializeObjectToFile(Object object, String filename) Serializes object into filename . FileOutputStream fos = null; ObjectOutputStream out = null; try { fos = new FileOutputStream(filename); out = new ObjectOutputStream(fos); out.writeObject(object); out.close(); } catch (IOException ex) { ... |
byte[] | serializer(Object object) serializer ObjectOutputStream objectOutputStream = null; ByteArrayOutputStream byteArrayOutputStream; try { byteArrayOutputStream = new ByteArrayOutputStream(); objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); objectOutputStream.writeObject(object); objectOutputStream.flush(); return byteArrayOutputStream.toByteArray(); ... |
byte[] | serializeSafe(T obj) serialize Safe ByteArrayOutputStream baos = null; try { baos = new ByteArrayOutputStream(); ObjectOutput out = null; try { out = new ObjectOutputStream(baos); obj.writeExternal(out); out.flush(); ... |
int | serializeShort(short value, byte[] outbuf, int offset) Serialize a short, but do not convert it to little endian in the process outbuf[offset++] = (byte) (value >> 8); outbuf[offset++] = (byte) (value); return offset; |
void | serializeString(File file, String string) Dump a String to a text file.
serializeString(file, string, null); |
String | serializeToBase64(Serializable object) serialize To Base if (object == null) { return ""; ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); ObjectOutputStream objectStream = null; try { objectStream = new ObjectOutputStream(byteArrayStream); objectStream.writeObject(object); ... |
void | serializeToFile(Object obj, String fileName) serialize To File ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(fileName))); out.writeObject(obj); out.close(); |
void | serializeToFile(Object object, File file) Utility method to serialize an object to the given File. ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file))); oos.writeObject(object); oos.close(); |
void | serializeToFile(Serializable s, String path) serialize To File FileOutputStream fileOut = new FileOutputStream(path);
serialize(s, fileOut);
fileOut.close();
|