How to read a big binary file in Java -
i want read binary file in java, contains m datasets. know each dataset consists of 3 elements: long number, double number , long number in sequence. datasets repeated 1 after each other till end of file. supposing number m of datasets known, how can read file in java without passing datasets main memory, able read large files well, not "fit" in main memory?
if want sequential access:
import java.io.fileinputstream; import java.io.datainputstream; datainputstream dis = new datainputstream(new fileinputstream("input.bin")) for(int = 0; < m; i++){ long l1 = dis.readlong(); double d1 = dis.readdouble(); long l2 = dis.readlong(); /* need */ } dis.close();
Comments
Post a Comment