OK,找到问题所在了。
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5026745
里面提到:
---------------------------
OK, I have to admit that it works in 1.5.0-b64.
But not the way described above.
You have to use HttpURLConnection.setChunkedStreamingMode(len).
---------------------------
需要设定每次发送数据的大小,否则它将按照默认的缓冲大小4k
而我使用的缓冲是 16K, 所以设定 conn.setChunkedStreamingMode(1024 * 16). 就没有问题了。
> Date: 2008-9-10 20:42遇到这样的现象:通过浏览器上传一个大文件时(300多m)没有问题。但用java程序连接服务器发送该文件数据就会出错。