Buffered writer in java

We can even use Buffered writer . File writer writes data to Buffered writer and the buffered writer only writes data in size able chunks once in a while.

public static void main(String[] args) throws IOException {
   try(BufferedWriter locfile = new BufferedWriter(new FileWriter("locations2.txt"));         
     BufferedWriter directionfile = new BufferedWriter(new FileWriter("directions2.txt"));)    
       {//loop over locations map that contains values of type location     
        for (location location : locations.values()) {  
           //get location id and description  
           locfile.write(location.getLocationId() + "," + location.getDescription() + "\n");      
         //get location exits map and then get keys from it.        
           for(String direction : location.getExits().keySet()){        
            directionfile.write(location.getLocationId()+","+direction+","+location.getExits().get(direction)+"\n");      
            } 
           }
         }