I am having a problem in the following conversion. The file becomes scrambled and loses all its info.
here is the method I am using to convert:
private byte[] readFileToArray(Object object) throws IOException{
ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
ObjectOutputStream objectOutput = new ObjectOutputStream(byteArrayOutput);
objectOutput.writeObject(object);
objectOutput.flush();
objectOutput.close();
byteArrayOutput.close();
byte [] data = byteArrayOutput.toByteArray();
return data;
}
what should I do so that i don't lose the info in the files?