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.java2s.com"); URLConnection uc = u.openConnection(); uc.setIfModifiedSince(1000);/*from w w w. jav a 2 s. com*/ System.out.println(uc.getIfModifiedSince()); }
From source file:Main.java
public static void main(String args[]) throws Exception { URL u = new URL("http://www.java2s.com"); URLConnection uc = u.openConnection(); uc.setConnectTimeout(1000);/*from ww w. ja v a 2 s. com*/ System.out.println(uc.getConnectTimeout()); }
From source file:Main.java
public static void main(String[] args) { try {//from w w w .j ava 2s. c o m URL url = new URL("http://www.java2s.com/query?abc=def"); System.out.println("URL is " + url.toString()); System.out.println("authority is " + url.getAuthority()); System.out.println("default port is " + url.getDefaultPort()); System.out.println("query is " + url.getQuery()); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("http://hostname:80/image.gif"); Image image = Toolkit.getDefaultToolkit().getDefaultToolkit().createImage(url); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL("image address"); Toolkit t = Toolkit.getDefaultToolkit(); Image im = t.getImage(url);//from ww w .j av a2 s .c om }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("http://java2s.com"); URLConnection conn = url.openConnection(); for (int i = 0;; i++) { String headerName = conn.getHeaderFieldKey(i); String headerValue = conn.getHeaderField(i); System.out.println(headerName); System.out.println(headerValue); if (headerName == null && headerValue == null) { System.out.println("No more headers"); break; }//from www . j a va2 s . c o m } }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("http://hostname:80"); URLConnection conn = url.openConnection(); for (int i = 0;; i++) { String headerName = conn.getHeaderFieldKey(i); String headerValue = conn.getHeaderField(i); System.out.println(headerName); System.out.println(headerValue); if (headerName == null && headerValue == null) { System.out.println("No more headers"); break; }/* www . j a v a2 s. c o m*/ } }
From source file:Main.java
public static void main(String[] a) { try {//from www . j ava 2 s . c o m URL base = new URL("http://www.java2s.com/"); URL relative = new URL(base, "index.html"); System.out.println(relative); } catch (MalformedURLException ex) { ; } }
From source file:MainClass.java
public static void main(String[] args) throws MalformedURLException { URL u = new URL("http://www.java2s.com"); System.out.printf("hashcode: %h\n", u); }
From source file:MainClass.java
public static void main(String[] args) throws MalformedURLException { URL u = new URL("http://www.java2s.com"); System.out.printf("BOOLEAN: %B\n", u); }