清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
//一种方法是设置全局的代理,在程序中如下设置: System.setProperty("proxySet", "true"); System.setProperty("http.proxyHost", "192.168.7.33"); System.setProperty("http.proxyPort", "8080"); //还有一种就是在发送每次请求的时候设置代理: URL url = new URL("http://www.open-open.com"); Proxy proxy = new Proxy(Proxy.Type.DIRECT.HTTP, new InetSocketAddress("192.168.7.33", 8080)); HttpURLConnection conn = (HttpURLConnection) url.openConnection(proxy); InputStream in = conn.getInputStream(); BufferedReader bin = new BufferedReader(new InputStreamReader(in)); String s = null; while((s=bin.readLine())!=null){ System.out.println(s); } bin.close();