slicing and dicing of byte arrays

A

Andy Fish

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
 
J

John C. Bollinger

Andy said:
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
(e-mail address removed)
 
M

Michael Borgwardt

John said:
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.
 

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

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top