Question about rationale for java.nio.Buffer design.

Discussion in 'Java' started by Harald Kirsch, Jun 14, 2004.

  1. Hi,

    asked to write a buffer implementation, I would
    go for an array a read pointer and a write pointer
    and would just wrap them around at the end of the
    array, making sure that they don't overtake each
    other.

    Writing and reading would be possible at any time
    if the buffer is not full or resp. empty.

    Compare this with the tedious and confusing
    (my opinion) interface of java.nio.Buffer design:

    When you want to write to the buffer, do you first
    do a flip(), clear() or rewind() or do you first
    scratch your head and wonder which one now?

    Does remaining() tell you how much room there is or
    how much data is available?

    Can anyone give me some reason why they choose this
    buffer interface and implementation? It probably
    would help me to understand when to do what.

    Thanks,
    Harald.
     
    Harald Kirsch, Jun 14, 2004
    #1
    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. iksrazal

    NIO with timeouts != NIO?

    iksrazal, Jun 17, 2004, in forum: Java
    Replies:
    1
    Views:
    6,280
    iksrazal
    Jun 18, 2004
  2. John
    Replies:
    0
    Views:
    769
  3. Replies:
    2
    Views:
    2,691
    Andrey Kuznetsov
    May 16, 2006
  4. Vincent Cantin
    Replies:
    3
    Views:
    410
    Danno
    Jul 22, 2006
  5. Replies:
    6
    Views:
    6,247
Loading...

Share This Page