throw new IllegalStateException(e.getMessage());
}
}
public static byte[] serialize(Serializable obj) {
ObjectOutputStream oos = null;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(obj);
return baos.toByteArray();
} catch (NotSerializableException e) {
throw new IllegalStateException(e.getMessage());
} catch (IOException e) {
throw new IllegalStateException(e.getMessage());
} finally {
if (oos != null) {
try {
oos.close();
} catch (IOException e) {
throw new IllegalStateException(
"Failed to close stream to DiskCache, "
+ "cache may be corrupted. Reason: " + e.getMessage());
}