我有Object
一个
private String name;
private int age;
private String country;
// getters and setters
我将此对象转换为XML
使用JAXB
如下
OutputStream stream = new ObjectOutputStream(new FileOutputStream(getOutputFilePath(document.getUniqueId())));
write(proposal, stream);
和
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);
}
}
如何将其转换stream
为磁盘上的 Zip 文件?