int read(char[] cbuf, int off, int len)方法,每次读取len个字符放到字符数组cbuf中,从数组cbuf的下表off开始放,返回的是每次读取的字符个数。
public static void printByFileReaderChars(String filePath) throws IOException
{
BufferedReader reader=new BufferedReader(
new FileReader(filePath)
);
if(!reader.ready())
{
System.out.println("文件流暂时无法读取");
return;
}
int size=0;
char[] cbuf=new char[20];
while((size=reader.read(cbuf, 0, cbuf.length))!=-1)
{
System.out.print(new String(cbuf,0,size));
}
reader.close();
}