I am trying to write a value fetched from a hashmap into a file :
public writeToFile(HapshMap<String,String> , String fileName) {
File myFile = new File(filePath);
BufferedWriter bufferedWriter = null;
Writer writer = new FileWriter(myFile,false);
bufferedWriter = new BufferedWriter(writer);
String paramsValue = params.get("NAME");
bufferedWriter.write(paramsValue);
}
In the above code , the key "NAME" is not there in the HashMap. And it is throwing NPE .Can anyone suggest what can be done and why is NPE getting thrown?