Damir
Damir

Reputation: 56249

How do I append a byte[] to a List<Byte>?

How do I append the elements of a byte[] to a List<Byte>?

Upvotes: 3

Views: 2415

Answers (2)

ColinD
ColinD

Reputation: 110104

Using Guava, you could use Bytes.asList(byte...) like this:

List<Byte> list = ...
byte[] bytes = ...
list.addAll(Bytes.asList(bytes));

Upvotes: 5

Johan Sj&#246;berg
Johan Sj&#246;berg

Reputation: 49237

Is this what you're looking for?

for(byte b : byte) {
    list.add(b);
}

Upvotes: 8

Related Questions