I have a RandomAccessFile
and I want to read fixed sized buckets of ints from this file, but each of them starts at different locations. What I am doing is creating a new DataInputStream(new BufferedInputStream(new FileInputStream(rfile2.getFD()), bucketSize))
and before reading the bucket, I use rfile2.seek(startPosition). Then I get the elements by using DataInputStream
's method Readint
.
Is this a correct approach? Would using FileInputStream
's method read
make it faster?