Java Properties Load from File loadProperties(File file)

Here you can find the source of loadProperties(File file)

Description

Load Properties from a File .

License

Open Source License

Declaration

public static Properties loadProperties(File file) 

Method Source Code


//package com.java2s;
/*/*  w w  w.j  a va  2s  .  c  o  m*/
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 * 
 *    (C) 2005-2010, Open Source Geospatial Foundation (OSGeo)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

public class Main {
    /**
     * Load {@link Properties} from a {@link File}.
     */
    public static Properties loadProperties(File file) {
        try {
            InputStream input = null;
            try {
                input = new BufferedInputStream(new FileInputStream(file));
                Properties properties = new Properties();
                properties.load(input);
                return properties;
            } finally {
                if (input != null) {
                    input.close();
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. loadParams(String fileName)
  2. loadPriority()
  3. loadProperties(File directory, String propertiesFileName)
  4. loadProperties(File f)
  5. loadProperties(File file)
  6. loadProperties(File file)
  7. loadProperties(File file)
  8. loadProperties(File file)
  9. loadProperties(File file)