//对于不是特别大的文件,我想这个只需要读取文件一次就可以了。所以可取。特大文件就 不行了。
InputStream in=new FileInputStream("D:\\test\\changes.txt");
byte[]b=new byte[in.available()];
in.read(b);
String []line=new String(b).split("\\n");
System.out.println(line.length);//总行数
System.out.println(line[900].replaceAll("\\r", ""));//第900行数据
InputStream in=new FileInputStream("D:\\test\\changes.txt");
byte[]b=new byte[in.available()];
in.read(b);
String []line=new String(b).split("\\n");
System.out.println(line.length);//总行数
System.out.println(line[900].replaceAll("\\r", ""));//第900行数据