Here you can find the source of loadProperties(String propsFile)
Parameter | Description |
---|---|
propsFile | location of the properties file |
public static Properties loadProperties(String propsFile)
//package com.java2s; /*/*from w w w. j a v a 2s .c om*/ * Copyright 2008 The MITRE Corporation (http://www.mitre.org/). All Rights Reserved. * * 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 { /** * Creates a new Properties object from the properties file located at the * argument location * *@param propsFile location of the properties file *@return New properties object created from the file located at * the argument location */ public static Properties loadProperties(String propsFile) { Properties ret = new Properties(); try { File test = new File(propsFile); if (!test.exists()) { RuntimeException re = new RuntimeException("Could not find the properties file: " + propsFile); throw re; } InputStream in = new FileInputStream(propsFile); ret.load(in); } catch (IOException e) { RuntimeException re = new RuntimeException("Could not find the properties file: " + propsFile, e); throw re; } return ret; } }