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

oh_Boo 2013-11-15 03:41:19
这是我提交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 ..这是为什么?
...全文
139 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
oh_Boo 2013-11-15
  • 打赏
  • 举报
回复
_(:з」∠)_ 没有人知道原因了么?!
oh_Boo 2013-11-15
  • 打赏
  • 举报
回复
引用 1 楼 fangmingshijie 的回复:
流没有关闭。
没有关闭是!? 哪个地方!>>!!?!?!?
  • 打赏
  • 举报
回复
流没有关闭。

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧