Stream handling simplification in PropertiesUtil

- use resource block instead of finally block

Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>
This commit is contained in:
Laszlo Hornyak 2014-02-26 21:40:11 +01:00
parent 71bb436c8d
commit ca9dd457f9

View File

@ -168,12 +168,11 @@ public class PropertiesUtil {
* @param file the file to load from
* @throws IOException
*/
public static void loadFromFile(Properties properties, File file) throws IOException {
InputStream stream = new FileInputStream(file);
try {
public static void loadFromFile(final Properties properties, final File file)
throws IOException {
try (final InputStream stream = new FileInputStream(file)) {
properties.load(stream);
} finally {
IOUtils.closeQuietly(stream);
}
}
}