So I am trying to download and load an object from a file stored on a webserver. The code I use is inside a try-catch block in an AsyncTask:
URL url = new URL("http://www.mydomain.com/thefileIwant");
URLConnection urlConn = url.openConnection();
ObjectInputStream ois = new ObjectInputStream(urlConn.getInputStream());
foo = (Foo) ois.readObject();
ois.close();
I build the file with this code:
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("thefileIwant"));
oos.writeObject(foo);
oos.close();
When I try and read the object in the first piece of code I get an IOExecption that the UTF Data Format does not match UTF-8. I have tried re-building the file a couple of times and it always gives me the same error. Can I download an Object like this?