使用HttpURLConnection链接服务返回数据

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011791074/article/details/79962988
            URL url = new URL(urlStr); //url地址
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setDoOutput(true);
            con.setRequestProperty("Pragma:", "no-cache");
            con.setRequestProperty("Cache-Control", "no-cache");
            con.setRequestProperty("Content-Type", "text/xml"); //返回值类型
            con.setRequestMethod("POST");
            BufferedReader br = new BufferedReader(new InputStreamReader(con
                    .getInputStream()));
            String line = "";
            for (line = br.readLine(); line != null; line = br.readLine()) {
                resutl = resutl + line;
            }
阅读更多

没有更多推荐了,返回首页