developerinlondon
Programmer
I am using the URL class to fetch a long document from a remote machine, but it seems my program automatically disconnects after reading for about 1 minute 10 seconds. My code is something like the following :
any fix?
Code:
try {
// Send data
URL url = new URL(this.url);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
logger.debug("timeout is "+conn.getReadTimeout()); // this returns 0, so no timeouts according to API
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(this.xml_out);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
//conn.
String line;
while ((line = rd.readLine()) != null) {
this.xml_in += line + "\n";
}
wr.close();
rd.close();
return true;
} catch (Exception e) {
// todo : report error
logger.error(e.getMessage());
return false;
}
any fix?