URLConnection: getHeaderField(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);
}
}
}
Home
Java Book
Networking
Java Book
Networking
URLConnection:
- URLConnection
- URLConnection: connect() throws IOException
- URLConnection: getContentEncoding()
- URLConnection: getExpiration()
- URLConnection: getHeaderFields()
- URLConnection: getHeaderField(int n)
- URLConnection: getHeaderFieldKey(int n)
- URLConnection: getIfModifiedSince()
- URLConnection: getLastModified()
- URLConnection: getURL()
- URLConnection: setAllowUserInteraction(boolean allowuserinteraction)
- URLConnection: setDoOutput(boolean dooutput)
- URLConnection: setIfModifiedSince(long ifmodifiedsince)
- URLConnection: setRequestProperty(String key, String value)
- URLConnection: setUseCaches(boolean usecaches)