I was trying to serialize a ZipEntry object into a byte array and I've understood that it's not possible.
Here's what I'm doing:
ZipEntry entryToDocumentum = null;
for (ZipEntry oneEntry : entries) { //entries is a ZipEntry arraylist
if (oneEntry.getName().equals(details.getId()+"_"+details.getCodEntidade()+"_"+details.getNrDocumento()+".pdf")) {
entryToDocumentum = oneEntry;
}
}
byte[] entryBytes = serializeEntry(entryToDocumentum);
serializeEntry method:
private static byte[] serializeEntry(Object obj) throws IOException {
ByteArrayOutputStream b = new ByteArrayOutputStream();
ObjectOutputStream o = new ObjectOutputStream(b);
o.writeObject(obj); //here is where I get the NotSerializable exception
return b.toByteArray();
}
If a ZipEntry is not serializable, how can I convert a ZipEntry to a byte array?