I’m reading a binary file and storing each record into a byte[]. Now I’d like to collect these records into a Java Vector. (So that it can grow indefinitely.) But Vector takes Objects, not primitives (or arrays of primitives, as far as I can tell).
Is there way to “box” an array of primitives, or am I going to have to rewrite my code to turn my arrays into Arrays and my bytes into Bytes?
I tried concatenating the bytes into a String, but that failed miserable, due to String.append()‘s propensity to treat my bytes as ints and convert them into String-y decimal representations!!
byte[]is-anObject(all arrays are, even primitive ones). There is nothing stopping you from adding abyte[]to aVector.Though it doesn’t smell like a good design. Also, you should favour passing around
List(the interface) over passing around aVector(a concrete implementation ofList).