Hi!
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("http://blabla.com");
HttpURLConnection conn;
try
{
conn = (HttpURLConnection) url.openConnection();
//disconnect to change Request Method
conn.disconnect();
conn.setRequestMethod("HEAD");
//and connect again
conn.connect();
BufferedReader input = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while((line = input.readLine()) != null)
{
System.out.println(line);
}
input.close();
} catch (IOException ioe) {
System.out.println("IOException " + ioe.getMessage());
}
}
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("http://blabla.com");
HttpURLConnection conn;
try
{
conn = (HttpURLConnection) url.openConnection();
//disconnect to change Request Method
conn.disconnect();
conn.setRequestMethod("HEAD");
//and connect again
conn.connect();
BufferedReader input = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while((line = input.readLine()) != null)
{
System.out.println(line);
}
input.close();
} catch (IOException ioe) {
System.out.println("IOException " + ioe.getMessage());
}
}