浙江省高等学校教师教育理论培训

微信搜索“教师资格证岗前培训”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

//proxy
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("conf/system.properties");
       Properties properties = new Properties(); 
        try {
            properties.load(inputStream);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            logger.debug("load system.properties failure...");
        } 
        String r=properties.getProperty("crawlNode.httpProxy", "none").toLowerCase().trim();
        if (!r.equals("none")){
            String[] arr=StringUtils.split(r, ":");
            int port=80;
            String url=r;
            if (arr.length==2)
            {
                port=Integer.parseInt(arr[1]);
                url=arr[0].trim();
            }
            HttpHost proxy = new HttpHost(url, port);
            params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
            logger.debug("start using http proxy {}:{}",url,port);
           
        }

posted on 2012-05-03 11:48  lexus  阅读(352)  评论(0编辑  收藏  举报