我正在编写一个 java 代码来将 POST 请求发送到一个 URL,但它被挂在粗体表示的行上。我在安卓模拟器上运行这个
URL url = new URL("htt
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
OutputStream urlc = connection.getOutputStream(); //line on which code is getting hanged
OutputStreamWriter writer = new OutputStreamWriter(urlc);
writer.write("message");
writer.close();
我也可以在模拟器浏览器上运行互联网。那就是我检查了互联网是否正常工作。