tags:

views:

2083

answers:

1

I am constructing an array of bytes in java and I don't know how long the array will be.

I want some tool like Java's StringBuffer that you can just call .append(byte b) or .append(byte[] buf) and have it buffer all my bytes and return to me a byte array when I'm done. Is there a class that does for bytes what StringBuffer does for Strings? It does not look like the ByteBuffer class is what I'm looking for.

Anyone have a good solution?

+16  A: 

ByteArrayOutputStream You have to use write( byte[], int, int ) but it will grow as needed.

Clint
yes, this looks like it will do the trick. Thanks!
jbu
Have a couple of badges. +1
Michael Myers