public static void saveProperties(String file, String title, Map props) throws IOException {
      BufferedWriter bw = null;
      OutputStreamWriter osw = null;

      final char[] NEWLINE = System.getProperty("line.separator").toCharArray();
		
      File f = new File(file);
      FileOutputStream fos = new FileOutputStream(f, false);
      try {
         // write UTF8 BOM mark
         final byte[] bom = new byte[] { (byte)0xEF, (byte)0xBB, (byte)0xBF };
         fos.write(bom);

         osw = new OutputStreamWriter(fos, "UTF-8");
         bw = new BufferedWriter(osw);

         if (title != null) {
            title = "## " + title;
            osw.write(title.toCharArray(), 0, title.length());
            osw.write(NEWLINE, 0, NEWLINE.length);
         }

         Iterator iter = props.entrySet().iterator();
         while(iter.hasNext()) {
            Map.Entry entry = (Map.Entry)iter.next();
            
            String key = (String)entry.getKey();
            String val = (String)entry.getValue();
            osw.write(key.toCharArray(), 0, key.length());
            osw.write('=');
            if (val.length() > 0)
               osw.write(val.toCharArray(), 0, val.length());
            osw.write(NEWLINE, 0, NEWLINE.length);
         }

      } catch (IOException ex) {
         throw ex;
      } finally {
         try { bw.close(); fos.close(); } catch (Exception ex) { }
      }
   }