So, I am trying to upload and download an object from a file stored on a web server. The code I use is inside the try-catch block in 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 am creating a file using this code:
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("thefileIwant")); oos.writeObject(foo); oos.close();
When I try to read an object in the first code snippet, I get an IOExecption that the UTF data format is not UTF-8 compatible. I tried rebuilding the file a couple of times, and it always gives me the same error. Is it possible to load such an object?
Flynn source share