offsets in a FileChannel ...

Discussion in 'Java' started by qwertmonkey@syberianoutpost.ru, Feb 23, 2013.

  1. Guest

    > ... 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
     
    , Feb 23, 2013
    #1
    1. Advertising

  2. On 23.02.2013 15:54, wrote:
    >> ... 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?


    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

    --
    remember.guy do |as, often| as.you_can - without end
    http://blog.rubybestpractices.com/
     
    Robert Klemme, Feb 23, 2013
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Spendius
    Replies:
    4
    Views:
    2,330
    Harald Hein
    Jul 4, 2003
  2. Roedy Green
    Replies:
    3
    Views:
    3,290
    Roedy Green
    Aug 14, 2003
  3. Spendius
    Replies:
    0
    Views:
    427
    Spendius
    Sep 7, 2003
  4. Replies:
    4
    Views:
    224
    Roedy Green
    Feb 26, 2013
  5. Replies:
    0
    Views:
    186
Loading...

Share This Page