Java API Tutorial - Java HttpURLConnection HTTP_NO_CONTENT








Syntax

HttpURLConnection.HTTP_NO_CONTENT has the following syntax.

public static final int HTTP_NO_CONTENT

Example

In the following code shows how to use HttpURLConnection.HTTP_NO_CONTENT field.

import java.net.HttpURLConnection;
import java.net.URL;
//from   ww w.ja  va  2  s .  c  o  m
public class Main {
  public static void main(String[] argv) throws Exception {
    HttpURLConnection.setFollowRedirects(false);
    HttpURLConnection con = (HttpURLConnection) new URL("http://www.google.coom").openConnection();
    con.setRequestMethod("HEAD");
    System.out.println(con.getResponseCode() == HttpURLConnection.HTTP_NO_CONTENT);
  }
}