URLConnection: getHeaderFieldKey(int n) : URLConnection « java.net « Java by API






URLConnection: getHeaderFieldKey(int n)

 
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class MainClass {
  public static void main(String args[]) {
    URL u;
    URLConnection uc;
    String header;

    try {
      u = new URL("http://www.java2s.com");
      uc = u.openConnection();
      for (int j = 1;; j++) {
        header = uc.getHeaderField(j);
        if (header == null)
          break;
        System.out.println(uc.getHeaderFieldKey(j) + " " + header);
      }
    } catch (MalformedURLException e) {
      System.err.println("not a URL I understand.");
    } catch (IOException e) {
      System.err.println(e);
    }
  }

}

           
         
  








Related examples in the same category

1.URLConnection: connect() throws IOException
2.URLConnection: getContentEncoding()
3.URLConnection: getContentType()
4.URLConnection: getExpiration()
5.URLConnection: getHeaderFields()
6.URLConnection: getHeaderField(int n)
7.URLConnection: getInputStream()
8.URLConnection: getIfModifiedSince()
9.URLConnection: getLastModified()
10.URLConnection: getURL()
11.URLConnection: setAllowUserInteraction(boolean allowuserinteraction)
12.URLConnection: setDoInput(boolean doinput)
13.URLConnection: setDoOutput(boolean dooutput)
14.URLConnection: setIfModifiedSince(long ifmodifiedsince)
15.URLConnection: setRequestProperty(String key, String value)
16.URLConnection: setUseCaches(boolean usecaches)