2

抽象类Writer我们有这个抽象方法,它写入字符数组的一部分。

abstract public void write(char cbuf[], int off, int len) throws IOException;

Writer另请查看写入单个字符的类中的此方法:

public void write(int c) throws IOException {
        synchronized (lock) {
            if (writeBuffer == null){
                writeBuffer = new char[writeBufferSize];
            }
            writeBuffer[0] = (char) c;
            write(writeBuffer, 0, 1);
        }
    }

大小writeBufferSize = 1024。
我确信使用 1024 个位置的数组来拧一个字符是有充分理由的,谁能向我解释原因是什么?
谢谢

4

0 回答 0