Java – Convert byte [] to ArrayList
•
Java
I have a byte [], which I get using object ArrayList
Can someone tell me how to convert my byte [] to object ArrayList?
Coveting ArrayList
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = null;
oos = new ObjectOutputStream(bos);
oos.writeObject(mArrayList);//mArrayList is the array to convert
byte[] buff = bos.toByteArray();
thank you!
Solution
Now that you have provided us with information on how you can transform in some way... You need to:
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
try {
@SuppressWarnings("unchecked")
ArrayList<Object> list = (ArrayList<Object>) ois.readObject();
...
} finally {
ois.close();
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
