java - Get filepointer position while reading data from an ObjectInputStream -
i need current filepointer-position (in bytes) when read binary file. wrote file using objectoutputstream, , need read , remember byte-position of each object.
however: objectinputstream doesn't provide method read pointer position, , randomaccessfile cannot read objects :(
if think there's way, or workaround, information might help:
i have stored ids in file. each id lists @ least 1 node (can many nodes). long-values.
for example:
id node node ... 123151824812 12419512 1248129412 124912 5992039 1924823590 5238952323942 283492384 234892348 234908234 2348902348 5902303 239235523 ... each id individual object stores id-value long value, nodes arraylist<long>.
there's second file stores nodes , lists parenting ids of each node. this:
node id id ... 12419512 123151824812 234892348 5238952323942 27834918128911 ... the idea behind is: whenever know id , want know information node, node @ specific position in node-file. whenever know node , want know more parenting id, @ specific position in id file.
however did write id , node-values files using them "index".
i don't want line-for-line if that's id i'm looking for, these files can become large (gb-size). easier if remember byte-position of other file instead of line-index or so, because can jump using skip() or similar methods.
conclusion: how file pointer position (in bytes) beginning of next object while reading objectinputstream?
i have not tried this, typically create objectinputstream this
fileinputstream fis = new fileinputstream("filename.txt"); objectinputstream ois = new objectinputstream(fis); from fileinputstream, can call getchannel() returns filechannel. on filechannel there method position() returns current file position.
i think long have not buffering input stream in between, position() should return right value.
Comments
Post a Comment