Search code examples
javadata-structurestrie

How to store a data structure on a hard drive


I have made a trie data structure to store contacts in a contact book and need to know how I can make a permanent copy of the trie to my hard drive. I tried serializing the trie object but got the notSerializableException in Java. Is there anyway I can store the trie to any form of secondary memory without deconstructing the data structure and then reonstructing it when I open up my application again.


Solution

  • If you encountered NotSerializableException, please do as follows:

    • Check if all of your classes are Serializable
    • Be careful with inner class. Check if inner class is static, nonstatic inner class cannot be serialized.