This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hello everyone i had a difficulty in converting an arraylist into a byte array and again retrive it into an arraylist again. please letme knw how to do so if its short and possible for you send me a code synopsis
i had a difficulty in converting an arraylist into a byte array and again retrive it into an arraylist again.
The Collections API has methods to convert between ArrayList and an array of Object references. However, a byte is NOT and array of object references, it is a single object that can hold an array of byte primitive values. You will have to write code to iterate through the ArrayList or byte, converting values one at a time between object and primitive. Bill
Jim Yingst wrote:If the objects in the list are Serializable, you can user an ObjectOutputStream plus a ByteArrayOutputStream to create the array, and an ObjectInputStream plus a ByteArrayInputStream to recreate the list (creating copies of all the contents, most likely, unless the class of the objects is written to prevent that). Is that what you're trying to do?