T - the type of object which is to be deserializedpublic interface Deserializer<T>
The deserializer interface is designed as a utility interface, giving each implementation several methods for reading from URL's, files, byte arrays and more.
The only method to be implemented is fromStream(InputStream) which reads an object from a generic
input stream.
| Modifier and Type | Method and Description |
|---|---|
default T |
fromBytes(byte[] bytes)
Deserializes an object from a
byte[] using a ByteArrayInputStream. |
default T |
fromFile(File file)
Deserializes an object from a
File using a FileInputStream. |
default T |
fromResource(Class<?> clazz,
String resPath)
Deserializes an object from a
Class and a resource path by opening a stream to the resource via the
ClassLoader. |
T |
fromStream(InputStream stream)
Deserializes an object from an
InputStream. |
default T |
fromURL(URL url)
Deserializes an object from a
URL by opening a stream to it. |
T fromStream(InputStream stream) throws IOException
InputStream.stream - the streamIOException - if the deserialization failsdefault T fromFile(File file) throws IOException
File using a FileInputStream.file - the fileIOException - if the deserialization failsdefault T fromBytes(byte[] bytes) throws IOException
byte[] using a ByteArrayInputStream.bytes - the byte arrayIOException - if the deserialization failsdefault T fromResource(Class<?> clazz, String resPath) throws IOException
Class and a resource path by opening a stream to the resource via the
ClassLoader.clazz - the class which's class loader is to be usedresPath - the path to the resourceIOException - if the deserialization failsdefault T fromURL(URL url) throws IOException
URL by opening a stream to it.url - the urlIOException - if the deserialization failsCopyright © 2020. All rights reserved.