我怎样才能防止**”;java.net.ProtocolException:读取输入后无法写入输出“**”Java中的错误代码?
我试图将数据发送到url,但显示错误: java.net.ProtocolException:读取输入后无法写入输出 我认为发生错误是因为行我怎样才能防止**”;java.net.ProtocolException:读取输入后无法写入输出“**”Java中的错误代码?,java,http,http-headers,Java,Http,Http Headers,我试图将数据发送到url,但显示错误: java.net.ProtocolException:读取输入后无法写入输出 我认为发生错误是因为行int responseCode=connection.getResponseCode()我不知道 知道如何解决这个问题 URL Transmeter_Url = new URL(data); HttpURLConnection connection = (HttpURLConnection) Transmeter_Url.openConne
int responseCode=connection.getResponseCode()代码>我不知道
知道如何解决这个问题
URL Transmeter_Url = new URL(data);
HttpURLConnection connection = (HttpURLConnection) Transmeter_Url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type",Contetn_Type);
connection.setRequestProperty("Contetn-Length", Integer.toString(Post_Value.length()));
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-
US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");
int responseCode = connection.getResponseCode();
System.out.println("Get Response code:"+responseCode);
System.out.println("Reached here 7");
OutputStream outputStream = connection.getOutputStream();
System.out.println("Reached here 7");
outputStream.write(Post_Value.getBytes());
outputStream.flush();
outputStream.close();