私Object
は
private String name;
private int age;
private String country;
// getters and setters
と機能は
protected void write(@Nonnull final Document document, @Nonnull final OutputStream stream) throws PersistenceException {
try {
jaxbContext.createMarshaller().marshal(document, stream);
} catch (final JAXBException e) {
LOGGER.error(e.getMessage(), e);
throw new PersistenceException("Failed to marshall document " + docment.getUniqueId() + ": " + e.getMessage(), e);
}
}
zip
私はこれを次のようにファイルに変換します
ByteArrayOutputStream stream = new ByteArrayOutputStream();
write(document, stream);
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(new FileOutputStream(new File(getOutputFilePath(document.getUniqueId()))));
gzipOutputStream.write(stream.toByteArray());
これでzipファイルが作成されますが、開こうとすると、
gzip: document.xml.gz: unexpected end of file
私がここでやっていないのは何ですか?