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


 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;

  }

原文地址:https://www.cnblogs.com/jirglt/p/2936292.html