Code example for URLConnection

Methods: connect, setDoInput

0
     */ 
    private class TestURLStreamHandler extends URLStreamHandler {
        public URLConnection openConnection(URL arg0) throws IOException {
            try { 
                URLConnection con = arg0.openConnection();
                con.setDoInput(true);
                con.connect();
                return con;
            } catch (Throwable e) {
                return null; 
            } 
        } 
 
        public URLConnection openConnection(URL arg0, Proxy proxy)
                throws IOException { 
            return super.openConnection(u, proxy);
        } 
    } 
     
    /** 
     * Test method for {@link java.net.URL#URL(java.lang.String, java.lang.String, int, java.lang.String, java.net.URLStreamHandler)}.