NullPointerException while using put method of HashMap
Where is datamap initialised ? It's always null.
To clarify, you declare the variable and set it to null. But you need to instantiate a new Map, whether it's a HashMap or similar.
e.g.
datamap = new HashMap();
(leaving aside generics etc.)
Well, there are three objects accessed on that line. If nextLine[0] and nextLine[6] aren't null, because the println call above worked, then that leaves dataMap. Did you do dataMap = new HashMap(); somwehere?
HashMap<String, String> dataMap = new HashMap<String,String>();
Your dataMap
variable isn't initialized at this point. You should be getting a compiler warning about that.
dataMap is declared but not initialized. It can be initialized with
datamap = new HashMap();