日期:2014-05-20 浏览次数:21118 次
public int read(byte b[]) throws IOException { return read(b, 0, b.length); }
------解决方案--------------------
read()读取1个字节
read(byte[] b)将文本中的所有数据读取到b这个字节数组中
read(byte[] b, int off, int len)将文本中的所有数据读入到b字节数组的指定位置(这个貌似是这样
的,没有去测试)
如楼上所说,这些都是可以在帮助文档里面查到的~
------解决方案--------------------
//从源码可以看出来,他们本来就是同一个东西
public int read(byte b[]) throws IOException {
return read(b, 0, b.length);
}
public int read(byte b[], int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if (off < 0 || len < 0 || len > b.length - off) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return 0;
}
int c = read();
if (c == -1) {
return -1;
}
b[off] = (byte)c;
int i = 1;
try {
for (; i < len ; i++) {
c = read();
if (c == -1) {
break;
}
b[off + i] = (byte)c;
}
} catch (IOException ee) {
}
return i;
}
public abstract int read() throws IOException;
------解决方案--------------------
read()读取1个字节
read(byte[] b)将文本中的所有数据读取到b这个字节数组中
read(byte[] b, int off, int len)从流的第off个字节开始,读入长度为len的字节的数据
--signature-------------------
http://www.mowker.com/view/
------解决方案--------------------
API的干活