Java Network Classes Part2
Java Networking Tutorial Goto Part1 HttpURLConnection class It is the subclass URLConnection Provides support for HTTP connctions on port 80. to open a connection we use openConnection on a URL object and must cast the result to HttpURLConnection. methods getRequestMethod() getResponseCode() getResponseMessage() getHeaderFields() import java.net.* ; import java.io.* ; public class HttpURLDemo { public static void main (String[] args) throws IOException { URL hp = new URL( "http://www.google.com" ); HttURLConnection hpCon = (HttpURLDemo) hp. openConnection (); System. out . println ( "Request method is" +hpCon. getRequestMethod ()); System. out . println ( "Response code is" +hpCon. getResponseCode ()); System. out . println ( "Requst method is" +hpCon. getResponseMessage ()); Map<String>,List<String> hdrMap=hpCon. getHeaderFields ()); Set<String> hdrField = hdrMap. keySet