Here you can find the source of loadProperties(final URL url)
Parameter | Description |
---|---|
url | URL to load properties from. Must not be <code>null</code>. |
Parameter | Description |
---|---|
IOException | Reading error. |
public static Properties loadProperties(final URL url) throws IOException
//package com.java2s; /* This file is part of the project "Hilbert II" - http://www.qedeq.org * * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>. * * "Hilbert II" is free software; you can redistribute * it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *//* ww w . j a va 2 s .c o m*/ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; import java.net.URL; import java.util.Properties; public class Main { /** * Loads a property file from given URL. * * @param url URL to load properties from. Must not be <code>null</code>. * @return Loaded properties. * @throws IOException Reading error. */ public static Properties loadProperties(final URL url) throws IOException { Properties newprops = new Properties(); InputStream in = null; try { in = url.openStream(); newprops.load(in); } finally { close(in); } return newprops; } /** * Closes input stream without exception. * * @param in Input stream, maybe <code>null</code>. */ public static void close(final InputStream in) { if (in != null) { try { in.close(); } catch (Exception e) { // ignore } } } /** * Closes writer without exception. * * @param writer Writer, maybe <code>null</code>. */ public static void close(final Writer writer) { if (writer != null) { try { writer.close(); } catch (Exception e) { // ignore } } } /** * Closes out stream without exception. * * @param out Output stream, maybe <code>null</code>. */ public static void close(final OutputStream out) { if (out != null) { try { out.close(); } catch (Exception e) { // ignore } } } /** * Closes input reader without exception. * * @param reader Reader, maybe <code>null</code>. */ public static void close(final Reader reader) { if (reader != null) { try { reader.close(); } catch (Exception e) { // ignore } } } }