URL的三种连接方式

// 方法一 
           URL url = new URL("http://www.baidu.com");
           URLConnection urlcon = url.openConnection();
           InputStream is = urlcon.getInputStream();
          
// 方法二
           URL url = new URL("http://www.baidu.com");
           HttpURLConnection urlcon = (HttpURLConnection)url.openConnection();
           InputStream is = urlcon.getInputStream();
          
//方法三
           URL url = new URL("http://www.baidu.com");
           InputStream is = url.openStream();



你可能感兴趣的:(程序代码)