I’m developing a download-everything app for Android devices, and just a few URLs are giving me problems by throwing FileNotFoundException for some reason. I print out the URL and copy it to my browser and it works fine there, so I dont know what the problem is.
Exception:
W/System.err(14261): java.io.FileNotFoundException:
Code (minus most exception handling):
URL u = new URL(uri);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
c.setReadTimeout(readTimeout);
int totalSize = c.getContentLength();
InputStream in = null;
try {
in = c.getInputStream(); // Exception problem here
byte[] buffer = new byte[1024];
int len1 = 0;
................
Simply remove
c.setDoOutput(true);. DOh!Cheers harism.