java


Java: Premature EOF error when reading lines from webpage


I am iterating through webpages line-by-line and sometimes get java.io.IOException: Premature EOF. I have seen reports of people getting this error from reading characters, but not whole lines, so I'm not sure what to do to get rid of this.
The stack trace is:
Exception in thread "main" java.io.IOException: Premature EOF
at sun.net.www.http.ChunkedInputStream.readAheadBlocking(ChunkedInputStream.java:565)
at sun.net.www.http.ChunkedInputStream.readAhead(ChunkedInputStream.java:609)
at sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:696)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3336)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:161)
at java.io.BufferedReader.readLine(BufferedReader.java:324)
at java.io.BufferedReader.readLine(BufferedReader.java:389)
at crawler.Crawler.crawl(SEC_Crawler.java:63)
And the code that causes it is:
for (String webpage_address : Webpages) {
URL filing = new URL(webpage_address);
BufferedReader read_filing = new BufferedReader(new InputStreamReader(filing.openStream()));
for (String line = read_filing.readLine(); line != null; line = read_filing.readLine()) {
// Process line
}
}

Related Links

Java BigInteger prime numbers
c++ server htons to java ntohs client conversion
accessing an object array item, java
java api for simple gis computations
JXTA Applications on the iPhone
Cannot load an SQLite JDBC Driver, Any Ideas?
Which knowledge base/rule-based inference engine to choose for real time Runway incursion prevention system
Help I don't know how to handle this error (java.lang.RuntimeException: EMBEDDED Broker start failure:code = 1)
Error accessing a Web Service with SSL
How can Java assignment be made to point to an object instead of making a copy?
What is the difference between quicksort and tuned quicksort?
Simple Inversion of Control framework for Java/Scala
FindBugs and CheckForNull on classes vs. interfaces
Java RMI InitialContext: Equivalent of LocateRegistry.createRegistry(int)?
Suppress-catch or throw exceptions which can never occur?
Adding libraries in Eclipse JAVA with MAC OS

Categories

HOME
openstack
heroku
baqend
echarts
mouse
qore
iggrid
modx-revolution
postgres-xl
circuit
decimal
oxyplot
textfield
predix
hammerspoon
trading
angular2-aot
smb
pingfederate
web-api-testing
applozic
jspm
atlassian-crucible
subdomains
google-cloud-nl
tasklet
microsoft-chart-controls
sql-server-2012-express
binary-data
semantic-versioning
host
reportbuilder
lumberjack
dism
babel-core
long-polling
taffy
boost-multi-index
sage-one
mu
jxcore
sqlclient
iso8601
hittest
visual-c++-2008
google-feed-api
vmware-tools
py2app
angstrom-linux
php-parse-error
cartesian-product
mutation-observers
simple-framework
libressl
responsive-images
angular-local-storage
key-management
facebook-graph-api-v2.4
rake-task
codeigniter-routing
issuu
xceed-datagrid
mechanize-ruby
bundles
ember-charts
jmapviewer
tws
ril
jplaton
dice
dbproviderfactories
deobfuscation
hirefire
recent-documents
actionview
forums
meego
virtual-functions
zend-decorators
ugc

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App