祝你好运!
示例代码:
try {
URL object = new URL(url);
HttpURLConnection con = (HttpURLConnection) object.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestProperty("Content-Type", "application/json; charset=utf-8");
con.setRequestProperty("Accept", "application/json; charset=utf-8");
con.setRequestMethod("POST");
OutputStreamWriter wr= new OutputStreamWriter(con.getOutputStream());
wr.write(json);
wr.flush();
InputStream inputStream = con.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line = "";
while ((line=reader.readLine()) != null) {
response += "\n" + line;
}
如何获取回复状态? 请帮助!
答案 0 :(得分:0)
con.getResponseCode();`//获取状态