get Properties By Input Stream - Java java.util

Java examples for java.util:Properties File

Description

get Properties By Input Stream

Demo Code


//package com.java2s;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Main {

    public static Properties getPropertiesByInputStream(String propFileName) {
        Properties prop = new Properties();
        InputStream input = null;
        try {//  www .j av a 2s. co m
            input = new FileInputStream(propFileName);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            try {
                prop.load(input);
                input.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return prop;
    }
}

Related Tutorials