H
Hongyu
I have a java program that makes silent exit sometime, i.e., it doesn't
print out any error information when it exit. The program was designed
to repeatedly read the content from a web server by changing a query
parameter. The URL reader code is based on the simple java.net.URL
class, and looks like
//open reader for URL
InputStream is = new URL(urlString).openStream();
BufferedReader in = new BufferedReader(new InputStreamReader(is));
// read contents into a string buffer
while((int ch = in.read()) != -1) {
buffer.append((char)ch);
}
is.close();
By repeatedly calling the above URL reader, my java program can
continuously read tens of thousands of web pages, but then it somehow
can suddenly just stop working and exit. Based on tracing print lines,
I know the stop point is right at the "BufferedReader in = ..." line
most times, and ocasionally at the "buffer.append ..." line. But I
don't understand why URL class wouldn't throw any exception information
that user could catch, instead of a silent exit.
I would appreciate any enlightenment.
print out any error information when it exit. The program was designed
to repeatedly read the content from a web server by changing a query
parameter. The URL reader code is based on the simple java.net.URL
class, and looks like
//open reader for URL
InputStream is = new URL(urlString).openStream();
BufferedReader in = new BufferedReader(new InputStreamReader(is));
// read contents into a string buffer
while((int ch = in.read()) != -1) {
buffer.append((char)ch);
}
is.close();
By repeatedly calling the above URL reader, my java program can
continuously read tens of thousands of web pages, but then it somehow
can suddenly just stop working and exit. Based on tracing print lines,
I know the stop point is right at the "BufferedReader in = ..." line
most times, and ocasionally at the "buffer.append ..." line. But I
don't understand why URL class wouldn't throw any exception information
that user could catch, instead of a silent exit.
I would appreciate any enlightenment.