FileInputStream を開いている大きなファイルがあります。このファイルには、先頭からのオフセットとサイズを持ついくつかのファイルが含まれています。さらに、そのような含まれているファイルを評価するパーサーがあります。
File file = ...; // the big file
long offset = 1734; // a contained file's offset
long size = 256; // a contained file's size
FileInputStream fis = new FileInputStream(file );
fis.skip(offset);
parse(fis, size);
public void parse(InputStream is, long size) {
// parse stream data and insure we don't read more than size bytes
is.close();
}
これは良い習慣ではないように感じます。おそらくバッファリングを使用して、これを行うより良い方法はありますか?
さらに、skip() メソッドが読み取りプロセスを大幅に遅くしているように感じます。