title: writing a map into a file in java
body: <p>I have a arraylist of map and I need to write the keys of each map into a file seperated by pipe(|). keys of the next map in the next line and so on. I'm not familiar with file operations. Please help me</p>
  
  <p>EDIT- sorry for not including what I have did, I have done the following and its not writing line by line, many blank lines are inbetween</p>
  
  <pre><code>if(alPrdt.size()&gt;0)
  {
      if (!file.exists()) {
          System.out.println("no file. creating new file");
          file.createNewFile();
      }
      fw = new FileWriter(file.getAbsoluteFile(),true);
      bw = new BufferedWriter(fw);
      //s.writeObject(alPrdt);
      for(int i=0;i&lt;alPrdt.size();i++)
      {
          String temp = null;
          Map map=(Map) alPrdt.get(i);
          Iterator it=map.entrySet().iterator();
          while (it.hasNext()) {
              Map.Entry pairs = (Map.Entry)it.next();
              System.out.println("pairs:"+pairs.toString());
              if(pairs.getValue()==null)
                  temp = "";
              else
                  temp = pairs.getValue().toString();
  
              bw.write(temp);
              bw.write("|");
              it.remove();// avoids a ConcurrentModificationException
         }
         bw.write("\n");
  
      }
      bw.close();
  }
  </code></pre>