NewCoder NewCoder - 1 year ago 157
Java Question

How to Declare a Byte Array of Infinite Size/Dynamic in Java?

I am declaring a byte array which is of unknown size to me as it keeps on updating, so how can I declare the byte array of infinite size/variable size?

Answer Source

Arrays in Java are not dynamic. You can use list instead.

List<Byte> list = new ArrayList<Byte>();

Due to autoboxing feature you can freely add either Byte objects or primitive bytes to this list.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download