offsets in a FileChannel ...

Q

qwertmonkey

... You would have to create more complex code if you want to align char
position and byte position.
~
but then why do they have a:
~
docs/api/java/nio/channels/FileChannel.html#position()
~
in the API? How/What is it used for?
~
If you read the FileChannel.position() as you read off the chars from the
CharBuffer you always get 0 (as if the offset pointer in the underlying
FileChannel would not advance)
~
I am using:
~
$ java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) Client VM (build 23.6-b04, mixed mode)
~
lbrtchx
 
R

Robert Klemme

position and byte position.
~
but then why do they have a:
~
docs/api/java/nio/channels/FileChannel.html#position()
~
in the API? How/What is it used for?
http://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#position()

~
If you read the FileChannel.position() as you read off the chars from the
CharBuffer you always get 0 (as if the offset pointer in the underlying
FileChannel would not advance)

Probably because you are not reading through the channel but mapping the
file into memory.

Please stop ripping your posting threads apart. Thank you.

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top