I'm not really sure why you're doing this manually, but consider using memory mapping for conciseness, like the code here (note spark has a ByteBufferInputStream implemented in util):
https://github.com/apache/incubator-spark/blob/master/core/src/main/scala/org/apache/spark/storage/DiskStore.scala#L85

(Probably not worth considering, but a slight rejiggering of this code would actually allow you to use the DiskStore.)