slicing and dicing of byte arrays

Discussion in 'Java' started by Andy Fish, Jun 21, 2004.

  1. Andy Fish

    Andy Fish Guest

    Hi,

    I would like to do some fairly simple operations on byte arrays like append
    one to another, or get a "substring" into another byte array. Are there any
    standard classes to do this? - I don't want to have a collection with each
    element as a single byte.

    Andy
    Andy Fish, Jun 21, 2004
    #1
    1. Advertising

  2. Andy Fish wrote:

    > I would like to do some fairly simple operations on byte arrays like append
    > one to another, or get a "substring" into another byte array. Are there any
    > standard classes to do this? - I don't want to have a collection with each
    > element as a single byte.


    The platform API does not offer such features, but it is relatively
    straightforward to write your own utility for such purposes.
    System.arraycopy() is your friend. There is no way to achieve what you
    want without copying elements around -- an array always owns its
    elements, so you can't ever get an "array view" of some underlying data
    structure (including another array).


    John Bollinger
    John C. Bollinger, Jun 21, 2004
    #2
    1. Advertising

  3. John C. Bollinger wrote:
    > The platform API does not offer such features, but it is relatively
    > straightforward to write your own utility for such purposes.
    > System.arraycopy() is your friend. There is no way to achieve what you
    > want without copying elements around -- an array always owns its
    > elements, so you can't ever get an "array view" of some underlying data
    > structure (including another array).


    Actually, you can do something like that, via the buffer classes in java.nio.
    Michael Borgwardt, Jun 22, 2004
    #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. Richard
    Replies:
    11
    Views:
    1,067
    Adam Maass
    Feb 1, 2006
  2. crash.test.dummy
    Replies:
    1
    Views:
    914
    Knute Johnson
    Feb 17, 2006
  3. Tobiah

    Slicing Arrays in this way

    Tobiah, May 2, 2007, in forum: Python
    Replies:
    14
    Views:
    450
    Tobiah
    May 3, 2007
  4. Martin Manns

    Slicing wrapped numpy arrays

    Martin Manns, Jan 13, 2008, in forum: Python
    Replies:
    3
    Views:
    352
    Robert Kern
    Jan 14, 2008
  5. Philipp
    Replies:
    21
    Views:
    1,109
    Philipp
    Jan 20, 2009
Loading...

Share This Page