你为什么要用这种方法,用字符缓冲流读取不是更好吗?
我复制了你的代码试了一下,可以读取,但是有点问题,就是定义的数组16384,如果只读取了一部分,剩余的打印的全是空格
那为何不直接使用byte[]读呢!
FileInputStream fin = new FileInputStream("test.txt");
byte[] bytes=new byte[4096];
int b;
while((b=fin.read(bytes))>0){
//读到b个字节到bytes[]里面了,这里可以处理了。
}
String x=""
while ( (ch=rd.read(charArray)) != -1 ){
x+=new String(charArray);
}
System.out.println(x);