The following code seems to work correctly because I can retrieve the contents of the URL ok, but I don't get any results from the getHeaderField() call. Any ideas?
URL url = new URL( urlstr );
HttpURLConnection con = (HttpURLConnection)
url.openConnection();
con.setRequestMethod( "GET" );
con.setDoInput( true );
con.setDoOutput( false );
con.connect();
// display header fields
for( int i=0 ; ; i++ )
{
String key;
if( (key = con.getHeaderFieldKey(i)) ==
null )
break;
System.out.println( key + " = "
+ con.getHeaderField(i) );
}
// etc.