字符串 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();
}