公司使用代理上網(wǎng)
          System.setProperty("proxySet""true");
                  System.setProperty(
          "proxyHost""192.168.0.254");
                  System.setProperty(
          "proxyPort""8080");
          URL u
          =new URL("http://www.sun.com");
                  URLConnection uc
          =u.openConnection();
                  uc.connect();
                  InputStream is
          =uc.getInputStream();
                  
          if(is!=null)
                      System.out.println(
          "Proxy Success");
                  
                  InetAddress.getByName(
          "www.sun.com");
          使用url連接上去都可以獲得inputstream
          但是InetAddress.getByName(www.sun.com);就java.net.UnknownHostException: www.sun.com
          那么這個代理到底怎么設(shè)置啊,大俠們速度..急
          posted on 2008-12-03 12:52 object 閱讀(966) 評論(4)  編輯  收藏
          Comments
          • # re: 各位大俠幫我解決一下代理問題
            隔葉黃鶯
            Posted @ 2008-12-03 14:13
            import java.net.*;

            System.setProperty("proxySet", "true");
            System.setProperty("proxyHost", "10.80.38.33");
            System.setProperty("proxyPort", "80");
            URL u=new URL("http://www.sun.com");
            URLConnection uc=u.openConnection();
            uc.connect();
            InputStream is=uc.getInputStream();
            if(is!=null)
            System.out.println("Proxy Success");

            InetAddress[] addr = InetAddress.getByName("www.sun.com");
            println addr[0].getHostAddress();

            輸出
            Proxy Success
            72.5.124.61

            沒問題。在你的代理服務(wù)器上訪問一下www.sun.com看看  回復(fù)  更多評論   
          • # re: 各位大俠幫我解決一下代理問題[未登錄]
            object
            Posted @ 2008-12-03 16:06
            @隔葉黃鶯

            不行啊,兄弟,行我就不郁悶了  回復(fù)  更多評論   
          • # re: 各位大俠幫我解決一下代理問題[未登錄]
            sorcerer
            Posted @ 2008-12-03 16:55
            用httpclient試試,我用可以的.  回復(fù)  更多評論   
          • # re: 各位大俠幫我解決一下代理問題[未登錄]
            object
            Posted @ 2008-12-04 09:53
            @sorcerer
            暈了,你這個就可以了,厲害,自己設(shè)置代理就不行.郁悶到頭了  回復(fù)  更多評論   

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
           
          主站蜘蛛池模板: 隆德县| 兴化市| 辛集市| 沁源县| 乌苏市| 巴里| 兴化市| 浦东新区| 肇庆市| 衡阳县| 太和县| 龙江县| 海淀区| 水富县| 平凉市| 罗源县| 霍林郭勒市| 仪征市| 晋州市| 泗水县| 图们市| 越西县| 公主岭市| 盐池县| 深泽县| 东安县| 怀柔区| 盘锦市| 浮梁县| 通山县| 满城县| 专栏| 南涧| 和田县| 林西县| 庄浪县| 师宗县| 日照市| 牡丹江市| 汽车| 麟游县|