This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes HttpURLConnection - Stream closed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "HttpURLConnection - Stream closed" Watch "HttpURLConnection - Stream closed" New topic

HttpURLConnection - Stream closed

marc spoon

Joined: Aug 08, 2001
Posts: 13
i change the Request Method to "HEAD" and try to write the Header to stdout, but i get an IOException "Stream closed".
Anyone knows why?
URL url = new URL("");
HttpURLConnection conn;
conn = (HttpURLConnection) url.openConnection();
//disconnect to change Request Method
//and connect again
BufferedReader input = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while((line = input.readLine()) != null)
} catch (IOException ioe) {
System.out.println("IOException " + ioe.getMessage());
Bill Siggelkow
Ranch Hand

Joined: Jun 27, 2001
Posts: 57
I would guess the problem is that you have disconnected ... You may not be allowed to reconnect after a disconnect ... the following quote is from the HttpUrlConnection javadoc for the disconnect method ...

Indicates that other requests to the server are unlikely in the near future. Calling disconnect() should not imply that this HttpURLConnection instance can be reused for other requests.

Bill Siggelkow
Jade Cove Solutions
jQuery in Action, 2nd edition
subject: HttpURLConnection - Stream closed
Similar Threads
HttpURLConnection got stack when trying to invoke
Performance Issue: HttpURLConnection
GET via URLConnection?
How to capture a response from a Server?
Issue with sending xml jaxb object to servlet body