Here you can find the source of loadProperties(File file)
Parameter | Description |
---|---|
file | file to load properties from. |
Parameter | Description |
---|---|
IOException | if I/O exception occurs. |
null
.
public static Properties loadProperties(File file) throws IOException
//package com.java2s; /*//from w w w .j a va2 s .com * Copyright 2001-2008 Aqris Software AS. All rights reserved. * * This program is dual-licensed under both the Common Development * and Distribution License ("CDDL") and the GNU General Public * License ("GPL"). You may elect to use one or the other of these * licenses. */ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; public class Main { /** * Loads properties from the specified file. * * @param file file to load properties from. * @return properties. Never returns <code>null</code>. * * @throws IOException if I/O exception occurs. */ public static Properties loadProperties(File file) throws IOException { FileInputStream input = null; try { input = new FileInputStream(file); Properties properties = new Properties(); properties.load(input); return properties; } finally { if (input != null) { try { input.close(); } catch (IOException e) { throw new RuntimeException("Failed to close file:\n" + e); } } } } }