今天用此方法write()时,显示可以用int参数类型,结果写入文件中显示结果不对,查看源码原来类型为int时,强转为char类型写入文件,char类型只有两个字节,而int是四个字节,所以就出错了
public void write(int c) throws IOException {
synchronized (lock) {
if (writeBuffer == null){
writeBuffer = new char[WRITE_BUFFER_SIZE];
}
writeBuffer[0] = (char) c;
write(writeBuffer, 0, 1);
}
}