Java Properties Load from InputStream loadProperties(Properties props, InputStream inputStream)

Here you can find the source of loadProperties(Properties props, InputStream inputStream)

Description

Convenience method used to load properties from the given file.

License

Open Source License

Parameter

Parameter Description
props the properties object to be loaded into
propertyFile the properties file to read

Declaration

private static void loadProperties(Properties props, InputStream inputStream) 

Method Source Code

//package com.java2s;
/**/*  w  w  w. jav  a2  s.  c om*/
 * The contents of this file are subject to the OpenMRS Public License
 * Version 1.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://license.openmrs.org
 *
 * 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.
 *
 * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
 */

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Properties;

public class Main {
    /**
     * Convenience method used to load properties from the given file.
     * 
     * @param props the properties object to be loaded into
     * @param propertyFile the properties file to read
     */
    private static void loadProperties(Properties props, InputStream inputStream) {
        try {
            InputStreamReader reader = new InputStreamReader(inputStream, "UTF-8");
            props.load(reader);
        } catch (FileNotFoundException fnfe) {
            System.out.println("Unable to find properties file" + fnfe);
        } catch (UnsupportedEncodingException uee) {
            System.out.println("Unsupported encoding used in properties file" + uee);
        } catch (IOException ioe) {
            System.out.println("Unable to read properties from properties file" + ioe);
        } finally {
            try {
                if (inputStream != null)
                    inputStream.close();
            } catch (IOException ioe) {
                System.out.println("Unable to close properties file " + ioe);
            }
        }
    }
}

Related

  1. loadProperties(InputStream inputStream)
  2. loadProperties(InputStream inputStream)
  3. loadProperties(InputStream inputStream)
  4. loadProperties(InputStream inputStream, Properties result)
  5. loadProperties(InputStream stream)
  6. loadPropertiesFileFromStream(InputStream stream)
  7. loadPropertiesFromStream(InputStream inputStream)
  8. loadPropertiesInputStreamToMap(InputStream propertiesInputStream)
  9. loadPropertiesStream(InputStream input)