.read()方法返回的是读取的内容吧,那么这段代码的倒数第二行第三行怎么解释呢?求各位大佬教导

File file = new File(fileName);
FileReader readIn = new FileReader(file);

int size = (int)file.length();

int charsRead = 0;

char[] content = new char[size];

while(readIn.ready())

charsRead += readIn.read(content, charsRead, size - charsRead);

readIn.close();

public int read(char [] c, int offset, int len)
这是filereader里read方法的方法名,用途是读取字符到c数组,返回读取到字符的个数
三个参数分别的意思是,将文件中内容读到数组c中,读取开始的索引是offset,读取长度是len,
而返回值是读取到的字符的个数。

所以你这里倒数第二第三行的意思很明显,
当能够继续读取时,将文件的未读部分(即charsread后面的部分)读取到content数组中,
因为不能够超出数组索引,所以第三个参数是size-charsread.
返回值是读取到的字符的长度,累加到charsread上就是已经读取过的字符长度。