java调用api方法


java访问api返回参数

public static void main(String[] args) throws IOException {


try {
String do_post = do_post("http://tool.bitefu.net/jiari/vip.php?d=20170101&apikey=123456");
System.out.println(do_post);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}
public static String do_post(String url) throws IOException {
StringBuilder json = new StringBuilder();
        URL clear_cache = new URL(url);
        URLConnection yc = clear_cache.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
        String inputLine = null;
        while ( (inputLine = in.readLine()) != null) {
            json.append(inputLine);
        }
        System.out.println(json);
        return json.toString();
    }

猜你喜欢

转载自blog.csdn.net/qq_39205291/article/details/78831017