62,614
社区成员
发帖
与我相关
我的任务
分享
public void write(String str) throws IOException {
write(str, 0, str.length());
}
也就是输出字符串,所以就是1
如果调用bw.write(mark);因为你传的值是int类型会进入这个 public void write(int c) throws IOException {
synchronized (lock) {
ensureOpen();
if (nextChar >= nChars)
flushBuffer();
cb[nextChar++] = (char) c;
}
}
注意看如果是int 会转成char类型,此时对应 Ascii 表。比如 Ascii 表中33对应“!”。 你可以将mark设置为33 看看,输出结果就是"!"