List of usage examples for java.net URL URL
public URL(String spec) throws MalformedURLException
From source file:Main.java
public static void main(String args[]) throws Exception { URL u = new URL("http://www.yourserver.com:80/abc/demo.htm"); System.out.println("The URL is " + u); System.out.println("The port part is " + u.getPort()); }
From source file:Main.java
public static void main(String args[]) throws Exception { URL u = new URL("http://www.yourserver.com/abc/demo.htm"); System.out.println("The URL is " + u); System.out.println("The protocol part is " + u.getProtocol()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("http://hostname:80/index.html"); System.out.println(url);/*from ww w . j a v a2 s . c o m*/ }
From source file:Main.java
public static void main(String args[]) throws Exception { URL u = new URL("http://www.java2s.com:80/index.html"); System.out.println("The URL is " + u); System.out.println("The user info is " + u.getUserInfo()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("http://hostname:80/index.html#_top_"); String protocol = url.getProtocol(); // http String host = url.getHost(); // hostname int port = url.getPort(); // 80 String file = url.getFile(); // index.html String ref = url.getRef(); // _top_ }
From source file:MainClass.java
public static void main(String[] args) throws Exception { URL url = new URL("http://www.yahoo.com:80/en/index.html?name=joe#first"); System.out.println("protocol:" + url.getProtocol()); System.out.println("prot:" + url.getPort()); System.out.println("host:" + url.getHost()); System.out.println("path:" + url.getPath()); System.out.println("file:" + url.getFile()); System.out.println("query:" + url.getQuery()); System.out.println("ref:" + url.getRef()); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL(args[0]); System.out.println("URL is " + url.toString()); System.out.println("protocol is " + url.getProtocol()); System.out.println("authority is " + url.getAuthority()); System.out.println("file name is " + url.getFile()); System.out.println("host is " + url.getHost()); System.out.println("path is " + url.getPath()); System.out.println("port is " + url.getPort()); System.out.println("default port is " + url.getDefaultPort()); System.out.println("query is " + url.getQuery()); System.out.println("ref is " + url.getRef()); }
From source file:MainClass.java
public static void main(String[] args) { try {//w w w . j ava 2 s .com URL u = new URL("http://www.java2s.com"); Object o = u.getContent(); System.out.println("I got a " + o.getClass().getName()); } catch (Exception ex) { System.err.println(ex); } }
From source file:GetURLParts.java
public static void main(String args[]) { try {/*from w w w . jav a 2s. co m*/ URL u = new URL("http://www.java2s.com"); System.out.println("The URL is " + u); System.out.println("The protocol part is " + u.getProtocol()); System.out.println("The host part is " + u.getHost()); System.out.println("The port part is " + u.getPort()); System.out.println("The file part is " + u.getFile()); System.out.println("The ref part is " + u.getRef()); } // end try catch (MalformedURLException e) { System.err.println("not a URL I understand."); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL u = new URL("http://127.0.0.1/test.gif"); URLConnection uc = u.openConnection(); uc.setUseCaches(false);/* w w w . ja v a2s.co m*/ long timestamp = uc.getLastModified(); }