Java Properties Load from File load(File file, Properties data)

Here you can find the source of load(File file, Properties data)

Description

Loads a properties file from file.

License

Apache License

Parameter

Parameter Description
file the file to load (quiet if <b>null</b> or file does not exist)
data the data read

Exception

Parameter Description
IOException in case of I/O problems

Declaration

public static void load(File file, Properties data) throws IOException 

Method Source Code


//package com.java2s;
/*/*  www. j  av  a 2  s .c  om*/
 * Copyright 2009-2016 University of Hildesheim, Software Systems Engineering
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.File;
import java.io.FileReader;

import java.io.IOException;
import java.util.Properties;

public class Main {
    /**
     * Loads a properties file from <code>file</code>.
     * 
     * @param file the file to load (quiet if <b>null</b> or file does not exist)
     * @param data the data read
     * @throws IOException in case of I/O problems
     */
    public static void load(File file, Properties data) throws IOException {
        if (null != file && file.exists()) {
            FileReader fr = null;
            try {
                fr = new FileReader(file);
                data.load(fr);
            } finally {
                if (null != fr) {
                    fr.close();
                }
            }
        }
    }
}

Related

  1. load(File file)
  2. load(File file)
  3. load(File file)
  4. load(File file)
  5. load(File file)
  6. load(File propertiesFile)
  7. load(final Class key, final String env, final Properties defaults)
  8. load(final Properties props, final Properties toLoad)
  9. load(final String folder, final String fileName)