List of usage examples for java.net URL openConnection
public URLConnection openConnection() throws java.io.IOException
From source file:Main.java
public static void main(String args[]) throws Exception { URL url = new URL("http://www.google.com"); URLConnection httpCon = (URLConnection) url.openConnection(); InputStream s = httpCon.getInputStream(); }
From source file:Main.java
public static void main(String args[]) throws Exception { URL url = new URL("http://www.google.com"); URLConnection httpCon = (URLConnection) url.openConnection(); URLConnection.setDefaultAllowUserInteraction(true); }
From source file:Main.java
public static void main(String args[]) throws Exception { URL url = new URL("http://www.google.com"); URLConnection httpCon = (URLConnection) url.openConnection(); long s = httpCon.getHeaderFieldDate("Date", 10000); System.out.println(s);/*from w w w . j a va2 s .com*/ }
From source file:Main.java
public static void main(String args[]) throws Exception { URL url = new URL("http://www.google.com"); URLConnection httpCon = (URLConnection) url.openConnection(); String s = httpCon.getHeaderField("Set-Cookie"); System.out.println(s);//from w w w . j a v a 2 s . c o m }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("jar:file:/c://my.jar!/"); JarURLConnection conn = (JarURLConnection) url.openConnection(); String entryName = conn.getEntryName(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("jar:file:/c://my.jar!/"); JarURLConnection conn = (JarURLConnection) url.openConnection(); JarEntry jarEntry = conn.getJarEntry(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { String encoding = "ISO-8859-1"; URL u = new URL("http://www.java2s.com"); URLConnection uc = u.openConnection(); String contentType = uc.getContentType(); int encodingStart = contentType.indexOf("charset="); if (encodingStart != -1) { encoding = contentType.substring(encodingStart + 8); }//from w ww. j av a2s . c o m InputStream in = new BufferedInputStream(uc.getInputStream()); Reader r = new InputStreamReader(in, encoding); int c; while ((c = r.read()) != -1) { System.out.print((char) c); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("jar:file:/c://my.jar!/"); JarURLConnection conn = (JarURLConnection) url.openConnection(); String entryName = conn.getEntryName(); // null }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("jar:file:/c://my.jar!/"); JarURLConnection conn = (JarURLConnection) url.openConnection(); url = conn.getJarFileURL();//w w w . j a v a2s. co m System.out.println(url); }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("jar:file:/c://my.jar!/"); JarURLConnection conn = (JarURLConnection) url.openConnection(); JarFile jarFile = conn.getJarFile(); System.out.println(jarFile);//from w ww . jav a 2 s . c om }