Get Array From ByteBuffer (If ByteBuffer doesn't have an array backing it)

Discussion in 'Java' started by res7cxbi@verizon.net, Jan 1, 2006.

  1. Guest

    Maybe i'm ignorant but how can you get a byte[] array from a
    java.nio.ByteBuffer? (Even when the ByteBuffer does not have an array
    that backs it?) Im sure you can do this...

    And what are "relative" and "absolute" methods?

    thanks
    , Jan 1, 2006
    #1
    1. Advertising

  2. Re: Get Array From ByteBuffer (If ByteBuffer doesn't have an arraybacking it)

    wrote:
    > Maybe i'm ignorant but how can you get a byte[] array from a
    > java.nio.ByteBuffer? (Even when the ByteBuffer does not have an array
    > that backs it?) Im sure you can do this...


    http://download.java.net/jdk6/docs/api/java/nio/ByteBuffer.html#get(byte[])

    You need to create your byte[] first. There isn't an absolute version.

    > And what are "relative" and "absolute" methods?


    http://download.java.net/jdk6/docs/api/java/nio/Buffer.html

    "Transferring data

    "Each subclass of this class defines two categories of get and put
    operations:

    "Relative operations read or write one or more elements starting at the
    current position and then increment the position by the number of
    elements transferred. If the requested transfer exceeds the limit then a
    relative get operation throws a BufferUnderflowException and a relative
    put operation throws a BufferOverflowException; in either case, no data
    is transferred.

    "Absolute operations take an explicit element index and do not affect
    the position. Absolute get and put operations throw an
    IndexOutOfBoundsException if the index argument exceeds the limit.

    "Data may also, of course, be transferred in to or out of a buffer by
    the I/O operations of an appropriate channel, which are always relative
    to the current position."

    Tom Hawtin
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
    Thomas Hawtin, Jan 1, 2006
    #2
    1. Advertising

  3. Guest

    thanks!
    , Jan 1, 2006
    #3
    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. Martin Schmid

    Backing up Project Files

    Martin Schmid, Oct 23, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    338
    Martin Schmid
    Oct 23, 2003
  2. Brian Mitchell
    Replies:
    2
    Views:
    2,909
    Brian Mitchell
    Feb 15, 2004
  3. J. Frank Parnell

    backing up an asp database

    J. Frank Parnell, Mar 3, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    402
    J. Frank Parnell
    Mar 3, 2005
  4. Micke
    Replies:
    6
    Views:
    7,359
    Remmel
    Jan 7, 2011
  5. Ike
    Replies:
    1
    Views:
    361
    Roedy Green
    Jan 12, 2006
Loading...

Share This Page