• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

java.io.IOException: Premature EOF

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys!

I am getting a java.io.IOException: Premature EOF - for some urls, yet different on each execution - after executing the following function. Any ideas?

 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You didn't give us the exception stack trace, which is a vital piece of debugging information, but your problem sounds like this post
 
Eva Lin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:You didn't give us the exception stack trace, which is a vital piece of debugging information, but your problem sounds like this post



Thanks for your reply.
I am not enough familiar with the debugging process. So i would appreciate if you could provide me further information on how to carry out the following change: "...not to read using BufferedReader but one byte at a time and put the read in a try-catch for EOFException. ".

Kind regards,
Eva Lin.
 
Eva Lin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No one?

Please, tell me what you mean when you talk about "I think the straight forward solution will be, not to read using BufferedReader but one byte at a time and put the read in a try-catch for EOFException."! And how can I give you the exception stack trace?
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eva Lin wrote:And how can I give you the exception stack trace?



Introduction to Java Stack Traces
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Please, tell me what you mean when you talk about "I think the straight forward solution will be, not to read using BufferedReader but one byte at a time and put the read in a try-catch for EOFException."! And how can I give you the exception stack trace?



instead of using



try



where inputChar is declared as a int or a char.
 
Eva Lin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay. Here we are!

I added the following command (i.e. ex.printStackTrace();) inside the catch block in order to show you the stack trace.
I really concern about the behavior of my application because the "stuck" comes from different urls in each execution...
Also, it is worth to notice that, after the installation of netBeans and the app-execution in a new machine, the app completed successfully!
But, this doesn't happen again! What the !@#$ is going on? How can I solve the bug?
Some guys told me about Thread.wait(1000); function but neither this worked out!
@Evan Caballero: can you explain with details what you mean?

 
Evan Caballero
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this :

 
Eva Lin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope.
Exactly the same behavior...
About 4 out of 84 pages (urls) refuse to completely downloaded....
No hope....
 
Evan Caballero
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the purpose of your application is to "download" pages over HTTP, you should take a look at HttpURLConnection. There are plenty of examples on the internet to show you how to use it.
 
Eva Lin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Evan Caballero wrote:If the purpose of your application is to "download" pages over HTTP, you should take a look at HttpURLConnection. There are plenty of examples on the internet to show you how to use it.



Yes. This is actually what i want...
Do you mean a modification like this one:


 
Evan Caballero
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpURLConnection conn = (HttpURLConnection) x.openConnection(); is better I think ;)
 
Eva Lin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.
Neither this does work...
As a newbie, I am not familiar with the stack trace.
Is there any way of using this kind information?
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Evan Caballero wrote:HttpURLConnection conn = (HttpURLConnection) x.openConnection(); is better I think ;)



To my knowledge, all the Java API HTTP/HTTPS classes use the same sun.* classes under the covers. If you have a problem with one, you'll have a problem with all.
this guy looks like he solved the problem by switching to the Apache HttpClient.
 
My pie came with a little toothpic holding up this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic