Java FileInputStream Read readFile(String path, Properties store)

Here you can find the source of readFile(String path, Properties store)

Description

Reads data from a properties file to a Properties object.

License

Apache License

Parameter

Parameter Description
path Path to the file.
store Properties object to store the data.

Exception

Parameter Description
IOException If the method failes to load the properties, an IOException will be thrown.
NullPointerException If path or store are null, a NullPointerException will be thrown.

Declaration

public static void readFile(String path, Properties store) throws IOException 

Method Source Code


//package com.java2s;
/*//w w  w . ja  v a  2s.  co  m
 * Copyright 2007-2009 Alexander Fabisch
 *
 * 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.*;
import java.util.Properties;

public class Main {
    /**
     * Reads data from a properties file to a Properties object.
     *
     * @param path
     *          Path to the file.
     * @param store
     *          Properties object to store the data.
     * @throws IOException
     *          If the method failes to load the properties, an IOException will be thrown.
     * @throws NullPointerException
     *          If path or store are null, a NullPointerException will be thrown.
     */
    public static void readFile(String path, Properties store) throws IOException {
        checkNullReference(path, store);
        store.load(new FileInputStream(path));
    }

    private static void checkNullReference(Object... objects) {
        for (Object o : objects) {
            if (o == null) {
                throw new NullPointerException("objects must not be null");
            }
        }
    }
}

Related

  1. readFile(String path)
  2. readFile(String path)
  3. readFile(String path)
  4. readFile(String path)
  5. readFile(String path, long offset)
  6. readFile(String path, String encoding)
  7. readFile(String path, String root, OutputStream out)
  8. readFile(String pPathToFile)
  9. readFile(String resource)