日期:2014-05-20 浏览次数:20950 次
public class Test {
public static void main(String[] args) {
System.out.println(read(3,9));
}
public static String read(int from ,int to){
String result="";
byte[] result2=new byte[to-from+1];
try{
FileInputStream fis=new FileInputStream("d:\\ss.txt");
BufferedInputStream bis=new BufferedInputStream(fis);
bis.skip(from-1);
bis.read(result2, 0, to-from+1);
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
return new String(result2);
}
}