javaserializationobjectsize

Java: Serializing unknown Arraysize


If I safe an Array and reload it, is there a possibility to get the size if its unknown? Thanks


Solution

  • It sounds like you're serializing and storing the individual objects in the array (after much reading between the lines). Use the ObjectOutputStream to store the array itself. If the objects stored in the array are serializable, they'll be stored too. When you deserialize you'll get the entire array back intact.