Reputation: 209
What does this error mean?
Below is my logcat output:
01-23 17:09:29.120: W/System.err(24339): java.io.EOFException
01-23 17:09:29.120: W/System.err(24339): at libcore.io.Streams.readAsciiLine(Streams.java:203)
01-23 17:09:29.120: W/System.err(24339): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:544)
01-23 17:09:29.120: W/System.err(24339): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:784)
01-23 17:09:29.120: W/System.err(24339): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
01-23 17:09:29.120: W/System.err(24339): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
01-23 17:09:29.130: W/System.err(24339): at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:270)
01-23 17:09:29.130: W/System.err(24339): at com.sfcca.coverflow.Store$downloadMagazine.doInBackground(Store.java:881)
01-23 17:09:29.130: W/System.err(24339): at com.sfcca.coverflow.Store$downloadMagazine.doInBackground(Store.java:1)
01-23 17:09:29.130: W/System.err(24339): at android.os.AsyncTask$2.call(AsyncTask.java:264)
01-23 17:09:29.130: W/System.err(24339): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
01-23 17:09:29.130: W/System.err(24339): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
01-23 17:09:29.130: W/System.err(24339): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
01-23 17:09:29.130: W/System.err(24339): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
01-23 17:09:29.130: W/System.err(24339): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
01-23 17:09:29.130: W/System.err(24339): at java.lang.Thread.run(Thread.java:856)
According to the logcat this is the part of the code whereby there's an error: I'm trying to retrieve image url from a server then download them
try {
HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream in = conn.getInputStream();
Log.i("im connected", "Download");
bmImg = BitmapFactory.decodeStream(in);
File filename;
try {
// GET EXTERNAL STORAGE, SAVE FILE THERE
File storagePath = new File(Environment.getExternalStorageDirectory(),"/Futsing/issue"+issueNumber+"/");
storagePath.mkdirs();
filename = new File(storagePath + "/page"+number+".jpg");
FileOutputStream out = new FileOutputStream(filename);
bmImg.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
in.close();
MediaStore.Images.Media.insertImage(getContentResolver(),filename.getAbsolutePath(), filename.getName(),
filename.getName());
// displayImage();
} catch (Exception e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
Upvotes: 1
Views: 9770
Reputation: 561
The problem in my case was the network connection that I was using for uploading the file. After switching the network connection(to my LAN wifi network) everything worked. I was testing it on my local server and was trying to upload the file using external network connection other then my LAN network. Hope this helps.
Upvotes: 2
Reputation: 2318
Try from this Android HttpsUrlConnection eofexception
Looks like you need to add
if (Build.VERSION.SDK != null && Build.VERSION.SDK_INT > 13) { urlConnect.setRequestProperty("Connection", "close"); }
Upvotes: 2
Reputation: 2106
EOFException means End Of File (EOF) Exception. EOF is used to indicate end of a file. Normally if you want to read a file till the end you perform a while operation with condition EOF has not reached.
It is somewhat similar to the '/0' present at end of string. EOF is instead used to mark the end of file
You might be trying to read the file after EOF has reached that will cause exception to be raised
Upvotes: 1