当前位置:编程学习 > JAVA >>

Java Posty一个二进制流 为什么.服务器接收到为空?

这是我提交byte数组的方法
public static InputStream post(String url, byte[] PostData) {
URL u = null;
HttpURLConnection con = null;
InputStream inputStream = null;
// 尝试发送请求
try {
u = new URL(url);
con = (HttpURLConnection) u.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type", "binary/octet-stream");
OutputStream outStream = con.getOutputStream();
outStream.write(PostData);
outStream.flush();
outStream.close();

} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
con.disconnect();
}
}

// 读取返回内容
try {
// 读取返回内容
inputStream = con.getInputStream();
} catch (Exception e) {
e.printStackTrace();
}
return inputStream;
}


然后..我在另外启了一个项目. 来接收发送的.
可是接收出来的是
InputStream in = request.getInputStream();
int length = in.available();

这里的 length 是0 ..这是为什么? http post octet-stream --------------------编程问答-------------------- 流没有关闭。 --------------------编程问答--------------------
引用 1 楼 fangmingshijie 的回复:
流没有关闭。

没有关闭是!? 哪个地方!>>!!?!?!? --------------------编程问答-------------------- _(:з」∠)_ 没有人知道原因了么?!
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,