Here you can find the source of load(String[] paths, String fileName)
Parameter | Description |
---|---|
paths | an array of strings containing target paths. |
fileName | the name of the property file. |
public static Properties load(String[] paths, String fileName)
//package com.java2s; /*************************************************************************** * Copyright (C) 2001, Patrick Charles and Jonas Lehmann * * Distributed under the Mozilla Public License * * http://www.mozilla.org/NPL/MPL-1.1.txt * ***************************************************************************/ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; public class Main { /**/*from ww w.j av a 2 s . c om*/ * Load the specified properties file from one of the specified set of * paths. * * @param paths an array of strings containing target paths. * @param fileName the name of the property file. * @return a populated set of properties loaded from the first file * found in the set of supplied paths. If no property file is found, * returns null. */ public static Properties load(String[] paths, String fileName) { Properties properties = null; File propertiesFile = null; try { String path = null; for (int i = 0; i < paths.length; i++) { path = paths[i] + File.separator + fileName; propertiesFile = new File(path); if (propertiesFile.exists()) break; } if (!propertiesFile.exists()) { System.err.println("FATAL: could not find file '" + fileName + "' in default search paths: "); for (int i = 0; i < paths.length; i++) { System.err.print("'" + paths[i] + "'"); if (i < paths.length - 1) System.err.print(", "); } System.err.println(); System.exit(1); } properties = refresh(propertiesFile.getAbsolutePath(), new FileInputStream(propertiesFile)); } catch (Exception e) { System.err.println("ERROR: couldn't load properties from '" + propertiesFile + "'"); } return properties; } /** * Refresh property settings from disk. */ public static Properties refresh(String name, FileInputStream fis) throws IOException { System.err.println("INFO: loading properties from " + name); Properties properties = new Properties(); properties.load(fis); return properties; } }