
eu.interedition.text.h2.SerializableDataStreamMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of text-core Show documentation
Show all versions of text-core Show documentation
Stand-off Markup/Annotation Text Model
The newest version!
package eu.interedition.text.h2;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
/**
* @author Gregor Middell
*/
public class SerializableDataStreamMapper implements DataStreamMapper {
@Override
public void write(T data, OutputStream stream) throws IOException {
final ObjectOutputStream objectStream = new ObjectOutputStream(stream);
objectStream.writeObject(data);
objectStream.flush();
}
@SuppressWarnings("unchecked")
@Override
public T read(InputStream stream, Class type) throws IOException {
final ObjectInputStream objectStream = new ObjectInputStream(stream);
try {
return (T) objectStream.readObject();
} catch (ClassNotFoundException e) {
throw new IOException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy