T - the type of object which is to be serializedpublic interface Serializer<T>
The serializer interface is designed as a utility interface, giving each implementation several methods for serializing to URL's, files, byte arrays and more.
The only method to be implemented is toStream(Object, OutputStream)
which writes an object into a generic output stream.
| Modifier and Type | Method and Description |
|---|---|
default byte[] |
toBytes(T object)
Writes the object into bytes
byte[] using a
ByteArrayOutputStream with unset capacity. |
default byte[] |
toBytes(T object,
int capacity)
Writes the object into bytes
byte[] using a
ByteArrayOutputStream with set capacity. |
default void |
toFile(T object,
File file)
Writes the object into a
File using a FileOutputStream. |
void |
toStream(T object,
OutputStream stream)
Writes the object into a
OutputStream. |
void toStream(T object, OutputStream stream) throws IOException
OutputStream.object - the objectstream - the output streamIOException - if an I/O error occursdefault void toFile(T object, File file) throws IOException
File using a FileOutputStream.object - the objectfile - the fileIOException - if an I/O error occursdefault byte[] toBytes(T object, int capacity) throws IOException
byte[] using a
ByteArrayOutputStream with set capacity.object - the objectcapacity - the byte buffer capacity used by the streamIOException - if an I/O error occursByteArrayOutputStream(int)default byte[] toBytes(T object) throws IOException
byte[] using a
ByteArrayOutputStream with unset capacity.object - the objectIOException - if an I/O error occursByteArrayOutputStream()Copyright © 2020. All rights reserved.