再一个问题,JDK源文件中的OutPutStream.java中的write方法有3个
1个是public abstract void write(int b) throws IOException;
2个是public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}
3个是 public void write(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;
}
for (int i = 0 ; i < len ; i++) {
write(b[off + i]);
}
}
第2个和第3个write互相调用,我就没看出来到底想做什么,如果长度是对的不是就会一直反复调用死循环么,我想看下System.out.print的原理是什么,但是翻到过后看不明白,好像没实现什么功能的
1个是public abstract void write(int b) throws IOException;
2个是public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}
3个是 public void write(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;
}
for (int i = 0 ; i < len ; i++) {
write(b[off + i]);
}
}
第2个和第3个write互相调用,我就没看出来到底想做什么,如果长度是对的不是就会一直反复调用死循环么,我想看下System.out.print的原理是什么,但是翻到过后看不明白,好像没实现什么功能的
解决方案 »
- 导入eclipse配置文件后项目报错,但不影响使用。
- 如何实现新邮件自动提醒功能
- 如何进一步提高JAVA学习
- java
- 在TOMCAT6.0中布署jsf工程时出异常(急求解决方案)
- 关于spring的学习,哪本书比较适合?
- 那位大哥会Struts(安装)?
- 请教高手怎么修改J2EE服务其中的端口啊?
- 那位有:《Building J2EE Applications with the Rational Unified Process》,书的电子版 ?
- Configuration problem: Cannot locate BeanDefinitionParser for element [***】
- 按规律生成字符串问题,在线等,有答案即结贴
- 这句简单的sql改成hql,谢谢
write(byte b[],int 0,int len)应该是为了方便我们使用在write(byte[] b)这个方法的基础上增加的一个方法吧。
for(int i=0;i<len;i++){
write(b[off+i]);
}
这是个递归,off+1会导致off==len==0而退出,不会出现死循环OutputStream中的write(byte b[])中的方法实现,没研究过,不知道是什么东西