public static void writeResultFile(String filename,Map<String,List<QueryResponseJSON>> resultMap) throws IOException {
  try (BufferedWriter bw=new BufferedWriter(new FileWriter(new File(filename)))){
    for (    Entry<String,List<QueryResponseJSON>> entry : resultMap.entrySet()) {
      for (      QueryResponseJSON hitJSON : entry.getValue()) {
        bw.write(hitJSON.getJSONString());
        bw.newLine();
      }
    }
  }
 }

public static void writeResultFile ( String filename , Map < String , List < QueryResponseJSON > > resultMap ) throws IOException { try ( BufferedWriter bw = new BufferedWriter ( new FileWriter ( new File ( filename ) ) ) ) { for ( Entry < String , List < QueryResponseJSON > > entry : resultMap . entrySet ( ) ) { for ( QueryResponseJSON hitJSON : entry . getValue ( ) ) { bw . write ( hitJSON . getJSONString ( ) ) ; bw . newLine ( ) ; } } } }
writes elements of the resultmap to output file , one line for each element , where each line is a string representation of the corresponding queryresponsejson object
