zoukankan      html  css  js  c++  java
  • java使用在线api实例

    字符串 strUrl为访问地址和参数

    public String loadAddrsApi() {
        StringBuffer sb;
        String strUrl = "https://api.apishop.net/common/postcode/getAddrs?apiKey=个人的apiKey";
        try {
            URL url = new URL(strUrl);
            URLConnection con = url.openConnection();
            BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
            String line;
            sb = new StringBuffer();
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }
            br.close();
        } catch (Exception e) {
            e.printStackTrace();
            sb = new StringBuffer();
        }
        return sb.toString();
    }
  • 相关阅读:
    hibernate hql
    数据库锁机制
    Spring 事物管理
    spring自动代理
    spring 其它增强类型
    spring
    mybatis动态sql
    SSH注解整合
    ssh整合
    错题解析
  • 原文地址:https://www.cnblogs.com/YeHuan/p/11866716.html
Copyright © 2011-2022 走看看