At the moment I have this:
try{
// Create file
FileWriter fstream = new FileWriter("output");
BufferedWriter out = new BufferedWriter(fstream);
Iterator mapIt = assignments.entrySet().iterator();
while (mapIt.hasNext()){
out.write(mapIt.next().toString()+";\n");
}
//Close the output stream
out.close();
}
The thing is, I can’t just take the toString() of iterator, I need to take out the key and the value separately so I can put some stuff between them in the outputfile. Does anyone know how I do this?
You will notice the iterator returns a Map.Entry which has
getKeyandgetValuemethods.Use those to get the respective items….something like
Note I put
Objectas the types of key and val, but you should specify the types according to however you defined the Map.