Posts

How can you store any complex data structure in a file and retrieve the file data as the same data structure into your java program easily?

We are going to use the Jackson APIs to demonstrate the above requirement. Using the following example, we can store any data structure in a file and load the same data structure into our Java Program using the same file. Pre-requisites: Download Jackson API jars(Jackson Core, Jackson Annotations, Jackson Databind) from  https://search.maven.org/ Once downloaded, add the above mentioned JARs to your classpath. Here, I am going to do an example for data structure ArrayList<LinkedHashMap> Step 1: Create sample class (DataStructure) which holds your data structure as a variable. import java.util.ArrayList; import java.util.LinkedHashMap; public class DataStructure {   public ArrayList<LinkedHashMap> data = new ArrayList<LinkedHashMap>();   public DataStructure() {   }   public DataStructure(ArrayList<LinkedHashMap> data) { this.data = data;   } } Step 2: Create a method to store the data structure to a File....
Recent posts