Java Properties Load from File load(Properties props, File f)

Here you can find the source of load(Properties props, File f)

Description

Load.

License

Apache License

Parameter

Parameter Description
props the props
f the f

Exception

Parameter Description
IOException Signals that an I/O exception has occurred.

Declaration

public static void load(Properties props, File f) throws IOException 

Method Source Code


//package com.java2s;
/*/*from   w  w  w.ja va  2  s.  c  o m*/
 * Copyright 2012 - 2015 Manuel Laggner
 *
 * 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.FileInputStream;

import java.io.IOException;
import java.io.InputStream;

import java.util.Properties;

public class Main {
    /**
     * Load.
     * 
     * @param props
     *          the props
     * @param f
     *          the f
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     */
    public static void load(Properties props, File f) throws IOException {
        InputStream is = null;
        try {
            is = new FileInputStream(f);
            props.load(is);
        } finally {
            if (is != null) {
                is.close();
            }
        }
    }

    /**
     * Load.
     * 
     * @param props
     *          the props
     * @param is
     *          the is
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     */
    public static void load(Properties props, InputStream is) throws IOException {
        try {
            props.load(is);
        } finally {
            is.close();
        }
    }
}

Related

  1. load(InputStream is)
  2. load(InputStream stream)
  3. load(Map map, String fileName)
  4. load(Properties properties, String fileName)
  5. load(Properties props, Collection filters, File basedir)
  6. load(Properties props, File file)
  7. load(Properties props, String filename)
  8. load(String file)
  9. load(String file)