I sent a stringed byte array which was initially a serialized object class to my php server side so that i can save it into my mysql database as a TEXT
String temp = new String(facetemplate, Charset.forName("UTF-8"));
String feat = new String(facefeatures, Charset.forName("UTF-8"));
I convert the String back to a byte array but when i wan to convert it back to an object it gives me
java.io.StreamCorruptedException: invalid stream header: 3F3F0573
This is how i did my conversion back to an object
public static Object DeSerialise(byte[] byteobject) throws IOException, ClassNotFoundException
{
ByteArrayInputStream in = new ByteArrayInputStream(byteobject);
ObjectInputStream is = new ObjectInputStream(in);
return is.readObject();
}
Serializing my object class
public static <T> void SerializeObject(Context context, T obj)
throws FileNotFoundException, IOException {
File cache = new File(context.getCacheDir(), config.FILE_NAME);
if (!cache.exists())
cache.createNewFile();
FileOutputStream fos = new FileOutputStream(cache);
ObjectOutputStream out = new ObjectOutputStream(fos);
out.writeObject(obj);
out.close();
}
but for further information on how i turned my class to bytes please see the link below
http://stackoverflow.com/questions/28673243/object-to-byte-arrray-conversion-and-byte-array-to-string-conversion[
^]
am not sure why but i am guessing it is because of the string conversion i did initially before sending it. Not really an expert so any help would be greatly appreciated. Thanks