public static void generateCSV(HashMap newMap) {

        String csv = "";
        Iterator it = newMap.entrySet().iterator();

        try {
            FileWriter writer = new FileWriter("C:\\Users\\David\\Desktop\\output.csv");
            while (it.hasNext()) {
                Map.Entry termEntry = (Map.Entry) it.next();
                writer.append(termEntry.getKey().toString());
                writer.append(",");
                writer.append(termEntry.getValue().toString());
                writer.append("\n");

            }
            writer.flush();
            writer.close();

        } catch (IOException ioe) {
            System.out.println(ioe);
        }

    }