Here you can find the source of loadProperties(File file)
Parameter | Description |
---|---|
file | The file |
Parameter | Description |
---|---|
IOException | In case of a reading error |
public static Properties loadProperties(File file) throws IOException
//package com.java2s; /**/*from w w w .j a va 2 s. co m*/ * Copyright 2009-2016 Three Crickets LLC. * <p> * The contents of this file are subject to the terms of the LGPL version 3.0: * http://www.gnu.org/copyleft/lesser.html * <p> * Alternatively, you can obtain a royalty free commercial license with less * limitations, transferable or non-transferable, directly from Three Crickets * at http://threecrickets.com/ */ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Properties; public class Main { /** * Loads properties from a file if it exists. * * @param file * The file * @return The properties * @throws IOException * In case of a reading error */ public static Properties loadProperties(File file) throws IOException { Properties properties = new Properties(); try { FileInputStream in = new FileInputStream(file); try { properties.load(in); } finally { in.close(); } } catch (FileNotFoundException x) { // This is allowed. } return properties; } }