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

How to unmarshall SOAP message created by .NET Soap Formatter through JAXB
Socket client (Emulator Android)/ Server (Eclipse)
How to pass a RegEx expression as a parameter in Java?
Appium forces JavaScript heap out of memory
Proxy object ClassCastException
Only one annotation is showing
JSPRIT CostMatrix TransportTime != than BackwardTime
How to run JUnit test from within jar while JUnit cannot find the test class
Form fields value are not processed correctly if there is a '=' in value
TimeStamp to date conversion failure
Incompatible types: double[][] can not be converted to double
Log4j file not excluded from Maven build
How to increment my row counter variable in my while loop?
BigQuery - streaming via java is very slow
How to pass data from popup menu to actionlistener
How to prune variations of same method obtained by use of Java reflection?

Categories

HOME
image
openmp
netbeans
c#-4.0
push-notification
session
sharepoint-designer
icloud
callback
mvvmcross
add
primary-key
metatrader4
dax
row
php-7.1
commonmark
task
size
windows-server-2012
transformation
google-cloud-speech
swiftlint
opencover
jasonette
excel-2007
devops
smb
vlsi
facebook-access-token
intel-pin
kannel
quote
lightswitch-2013
sql-server-2012-express
twilio-api
xquery-3.0
webtest
framemaker
commit
xmlreader
disassembling
adobe-premiere
bitbucket-pipelines
jquery-bootgrid
gzipstream
nxlog
node-sass
smartcontracts
pnotify
boost-multi-index
clean-architecture
svmlight
windows-mobile-6.5
epson
smart-table
pintos
android-fonts
libpng
savon
livequery
two-factor-authentication
hsv
content-length
jqgrid-formatter
computer-algebra-systems
embedded-code
riak-cs
sankey-diagram
key-management
lustre
gui-test-framework
relocation
asp.net-web-api-odata
java-metro-framework
expected-exception
didselectrowatindexpath
page-layout
bulkloader
jquery-mobile-dialog
factory-method
distutils
tinn-r
itmstransporter
nsnetservice
funscript
bluepill
onsubmit
winbugs14
inotifycollectionchanged
blitz++
gin
meego
iweb
photoshop-cs4
procedural-music
private-members
defensive-programming
mdac
ntvdm.exe

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App