Created
September 22, 2016 03:16
-
-
Save sks147/8b91131bec9335432f82f769d7983035 to your computer and use it in GitHub Desktop.
Send a request to www server using the HTTP protocol format using GET method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.net.*; | |
import java.util.*; | |
//Send a request to www server using the HTTP protocol format using GET method | |
public class GETMethod{ | |
public static void main(String args[]){ | |
URL u = null; | |
try{ | |
u = new URL("http://www.bbc.co.uk/accessibility/guides/"); | |
HttpURLConnection http = (HttpURLConnection) u.openConnection(); | |
http.setRequestMethod("GET"); | |
System.out.println(u + " was last modified at " + new Date(http.getLastModified())); | |
}catch (MalformedURLException ex){ | |
System.err.println(u + "is not a well defined url"); | |
}catch (IOException ex){ | |
System.err.println(ex); | |
} | |
System.out.println(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment