How do you read/write a Map, specifically a LinkedHashMap, from/to a text file? I've tried to use the Iterable interface, but that doesn't work because i have Map and Iterable can only take one argument.
Map code:
Map<String, String> m1 = new LinkedHashMap<String, String>(16, 0.75f, true);
m1.put("John Smith", "555-555-5555");
m1.put("Jane Smith", "444-444-4444");
I know I have to create a PrintWriter + BufferedWriter/PrintReader + BufferedReader objects to read/write to this text file, and then use some version of the hasNext() method to read until the file ends, I just am not sure how. Please help!
EDIT: I can't use the Serializable interface for this either, because I'm trying to write a Map to the text file, not individual entries, and there's no indexOf() method for Maps.