Java Path File Read nio loadProperties(Path filePath)

Here you can find the source of loadProperties(Path filePath)

Description

load Properties

License

Mozilla Public License

Declaration

public static Properties loadProperties(Path filePath) 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/.
 * /*from ww  w .  j a  va 2 s . co  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 Properties loadProperties(Path filePath) throws IOException {
        if (!Files.exists(filePath))
            return null;
        try (Reader r = Files.newBufferedReader(filePath)) {
            Properties props = new Properties();
            props.load(r);
            return props;
        }
    }
}

Related

  1. loadFile(final Path p)
  2. loadFile(Path file)
  3. loadFile(String path)
  4. loadFromFile(Path path)
  5. loadJSON(Path path)
  6. loadProperties(Supplier classLoader, String classpathResource)
  7. loadStrings(Path thePath)
  8. loadStringsFromFile(String pathToFile)
  9. loadTestPackets(final Path path)