java - RandomAccessFile vs FileChannel.open(path); -


what kind of filechannel object filechannel.open(path) method return?

is still random access allowed if following?

randomaccessfile ra = new randomaccessfile("randomindeed","rw");     filechannel fc1 = ra.getchannel(); 

what's difference between fc1 , following instance fc:

filechannel fc = filechannel.open(path); 

basically know differences between 2 objects above-created, hence fc1 , fc

thanks in advance.

the filechannel instance got randomaccessfile instance carries random access behaviour of object it's been created, in case fc1 synced ra object. can see it's described in javadoc

changing channel's position, whether explicitly or reading or writing bytes, change file position of originating object, , vice versa. changing file's length via file channel change length seen via originating object, , vice versa. changing file's content writing bytes change content seen originating object, , vice versa.

however filechannel instance created using filechannel.open() fc doesn't have behaviour. true filechannel instances got streams. guarantees view of file consistent among objects created same program. hope might you.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -