Here you can find the source of loadPropertiesFromFile(String fullFileName)
Parameter | Description |
---|---|
fullFileName | full name of the file |
public static Properties loadPropertiesFromFile(String fullFileName) throws Exception
//package com.java2s; /*/* ww w .ja v a2s .c o m*/ * This software is distributed under the terms of the FSF * Gnu Lesser General Public License (see lgpl.txt). * * This program is distributed WITHOUT ANY WARRANTY. See the * GNU General Public License for more details. */ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class Main { /** * Load all properties from a file * * @param fullFileName full name of the file * @return properties in the resource */ public static Properties loadPropertiesFromFile(String fullFileName) throws Exception { Properties props = new Properties(); loadPropertiesFromFile(props, fullFileName); return props; } /** * Load all properties from a file * * @param props properties to load file * @param fullFileName full name of the file * @return properties in the resource */ private static void loadPropertiesFromFile(Properties props, String fullFileName) throws Exception { InputStream is = null; try { // load all properties is = new FileInputStream(fullFileName); if (is != null) { props.load(is); is.close(); } } catch (FileNotFoundException fnfe) { throw new Exception("File (" + fullFileName + ") does not exist."); } catch (IOException ioe) { throw new Exception("Error reading file " + fullFileName + "."); } finally { try { if (is != null) is.close(); } catch (Exception ex) { is = null; } } } }