-1
所有美好的一天!如何獲得回覆狀態
示例代碼:
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;
}
如何得到迴應的狀態? 請幫忙!