public static void WriteToFile() { doc_score = sortByComparator(doc_score, false); try { FileWriter wrtr = new FileWriter("D:/IR/Assignment7/Pytest/part2/output/prediction.txt"); for (String key : doc_score.keySet()) { wrtr.write(key + " : " + doc_score.get(key) + " \n"); } wrtr.close(); } catch (Exception e) { e.printStackTrace(); } }