你看看jdk,inputstream的read的定义是什么!显然是第二个参数错了,正好抛的是BoundsException public int read(byte b[], int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } ........................* @param off the start offset in array <code>b</code> * at which the data is written.
os.write(buff,0,flag);
这句话,对于读取网络的数据来说is.available()是不可靠的。
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return 0;
}
........................* @param off the start offset in array <code>b</code>
* at which the data is written.