Java Path File Write nio saveProperties(Path filePath, Properties prop)

Here you can find the source of saveProperties(Path filePath, Properties prop)

Description

save Properties

License

Mozilla Public License

Declaration

public static void saveProperties(Path filePath, Properties prop) throws IOException 

Method Source Code

//package com.java2s;
/******************************************************************************
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0.  If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 * //ww  w .  ja v  a2s.c  o  m
 * Software distributed under the License is distributed on an "AS IS" basis, 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 
 * the specific language governing rights and limitations under the License.
 *
 * The Original Code is: FetchMailAtt
 * The Initial Developer of the Original Code is: William Wong (williamw520@gmail.com)
 * Portions created by William Wong are Copyright (C) 2015 William Wong, All Rights Reserved.
 *
 ******************************************************************************/

import java.io.*;
import java.nio.file.*;
import java.util.*;

public class Main {
    public static void saveProperties(Path filePath, Properties prop) throws IOException {
        if (Files.exists(filePath))
            Files.delete(filePath);
        try (Writer w = Files.newBufferedWriter(filePath)) {
            prop.store(w, "");
        }
    }
}

Related

  1. removeMatchingLines( final Map d1LineMap, final Path tableDir, final String table, final BufferedWriter errors)
  2. robustCheckWriteable(Path logFile)
  3. save(Object o, String path)
  4. saveFile(String path, String text)
  5. saveHeaders(Path path, ArrayList headers)
  6. saveTo(String path, InputStream in)
  7. saveToFile(String path, byte[] text)
  8. setPosixPermissions(String path, boolean ownerRead, boolean ownerWrite, boolean ownerExecute, boolean groupRead, boolean groupWrite, boolean groupExecute, boolean othersRead, boolean othersWrite, boolean othersExecute)
  9. srcImageToSavePath(String src, Path saveFolder)