黑马程序员技术交流社区

标题: RandomAccessFile 中出现的无限循环 [打印本页]

作者: saiqqww234    时间: 2016-5-5 20:42
标题: RandomAccessFile 中出现的无限循环
public void test3()throws Exception{
RandomAccessFile raf4=new RandomAccessFile(new File("lasttest"), "rw");
byte[] b=new byte[1024];
int  len;
while((len=raf4.read(b))!=-1){
raf4.seek(2);
System.out.println(new String(b, 0, len));
}
}
}

lasttest中为123456789.
控制台输出结果为
3456789
3456789
3456789
3456789
3456789
3456789
。。。。。无限循环




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2