java 提取字符文件某个区域的字符串

如文件a.txt,现在我想要提取这个文件里的第100个-第200个字符,而不把文件全部提取出来。
文件里有汉字,字母,符号等。上面写错了,是不先把文件全部提取出来,例如先转为String.
RandomAccessFile可以不唤前读取全部内容,如果文件很大,而且只需要其一裂链唤段内容,可以肆凯用此类
你可以用raf.readChar()去读100个字符,我这里直接用byte读的

public static String readText(String filePath) throws IOException{
RandomAccessFile raf=new RandomAccessFile(filePath, "r");
byte[] b=new byte[1024]; //定义一个读取缓冲
raf.skipBytes(100); //跳到100开始读入
raf.readFully(b);
String str =new String(b,"GBK");
if(str.length()>100){
str=str.substring(0, 100);
}
raf.close();
return str;
}
public static void main(String[] args) {
try {
String str=readText("c:\\test.txt");
System.out.println(str);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
InputStream in = null;
byte[] tempbytes = new byte[100];
in = new FileInputStream(fileName);
下面的方法就是从第100个字节开睁团始读取100长度的字节
in.read(tempbytes,100, 100);

至于你文件中如果有汉字的话就不好处理了锋毕,悉基橘因为他是双字节的
使用RandomAccessFile的skipBytes方法来试试吧!具体怎么做自己看着做吧!
把文件打开 放到strs里面
strs.substring(100,200);