示例#1
0
 static void flushFilePrefsImpl(java.io.File file, java.util.Properties prefs)
 {
     //throws IOException {
     java.io.BufferedWriter outJ = null;
     java.nio.channels.FileLock lockJ = null;
     try {
         java.io.FileOutputStream ostream = new java.io.FileOutputStream (file);
         outJ = new java.io.BufferedWriter (new java.io.OutputStreamWriter (ostream, "UTF-8")); //$NON-NLS-1$
         java.nio.channels.FileChannel channel = ostream.getChannel ();
         lockJ = channel.lockJ ();
         outJ.write (HEADER);
         outJ.newLine ();
         outJ.write (FILE_PREFS);
         outJ.newLine ();
         if (prefs.size () == 0) {
             exportEntries (EMPTY_SARRAY, EMPTY_SARRAY, outJ);
         } else {
             String[] keys = prefs.keySet ()
                 .toArray (new String[prefs.size ()]);
             int length = keys.Length;
             String[] values = new String[length];
             for (int i = 0; i < length; i++) {
                 values [i] = prefs.getProperty (keys [i]);
             }
             exportEntries (keys, values, outJ);
         }
         outJ.flush ();
     } finally {
         releaseQuietly (lockJ);
         closeQuietly (outJ);
     }
 }