公司使用代理上網(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
          那么這個(gè)代理到底怎么設(shè)置啊,大俠們速度..急
          posted on 2008-12-03 12:52 object 閱讀(966) 評(píng)論(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ù)  更多評(píng)論   
          • # re: 各位大俠幫我解決一下代理問題[未登錄]
            object
            Posted @ 2008-12-03 16:06
            @隔葉黃鶯

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

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


          網(wǎng)站導(dǎo)航:
           
           
          主站蜘蛛池模板: 瑞昌市| 通榆县| 遂川县| 大足县| 高安市| 万州区| 陆河县| 安化县| 黄龙县| 犍为县| 广东省| 红桥区| 和顺县| 景泰县| 布尔津县| 麦盖提县| 茶陵县| 河北区| 麻江县| 大安市| 玉溪市| 呼伦贝尔市| 南通市| 宣汉县| 昌平区| 安庆市| 江北区| 壶关县| 汤原县| 江川县| 会宁县| 靖远县| 九龙城区| 卢龙县| 平安县| 永德县| 通海县| 修武县| 平远县| 南京市| 曲沃县|