嘿,我正在尝试打开一个文件并仅从偏移量读取一定长度! 我读了这个话题: How to read a specific line using the specific line number from a file in Java? 在那里它说如果不读之前的行就不可能读到某一行,但我想知道字节!
FileReader location = new FileReader(file);
BufferedReader inputFile = new BufferedReader(location);
// Read from bytes 1000 to 2000
// Something like this
inputFile.read(1000,2000);
是否可以从已知偏移量读取某些字节?
最佳答案
RandomAccessFile公开一个函数:
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
关于java - 如何从Java中的某个偏移量读取文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9671126/