调用第三方接口的具体代码


 private String getKobe(String mburl)
 {
       URL url = null;
       BufferedReader reader = null;
       String str="";
       try
       {
               url = new URL(mburl);
               reader = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8"));
               String line=null;
               do
               {
                        line = reader.readLine();
                        if(line!=null)
                        {
                                str +=line;
                        }
                }
                while(line!=null);
         }
         catch (Exception e)
        {
               System.out.println("查询地址解析错误,"+e.getMessage());
               return "callfail";
        } 
        finally
       {
               if(reader != null)
              {
                     try
                     {
                             reader.close();
                     }
                     catch (IOException e)
                     {
                              e.printStackTrace();
                     }
                }
         }

          return str;

  }

posted on 2013-02-28 09:56  专注2018  阅读(408)  评论(0编辑  收藏  举报