import java.io.EOFException;
import java.io.RandomAccessFile;
public class Sample07 {
public static void main(String[] args) {
try{
RandomAccessFile ra = new RandomAccessFile("d://test.txt","r");
long count = Long.valueOf(args[1]).longValue();
long position = ra.length();
position -= count;
if(position<0)
position = 0;
ra.seek(position);
while(true){
try{
byte b = ra.readByte();
System.out.print((char) b);
}catch(EOFException eofe){
break;
}
}
}catch(Exception e){
e.printStackTrace();
}
}
}
java.lang.ArrayIndexOutOfBoundsException: 1
at day20.Sample07.main(Sample07.java:8)
运行出这个了。问题出哪里了 |