/**
 * Axelor Business Solutions
 *
 * Copyright (C) 2005-2017 Axelor (<http://axelor.com>).
 *
 * This program is free software: you can redistribute it and/or  modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.axelor.common;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

/**
 * The class provides static helper methods to work with resources.
 * 
 */
public final class ResourceUtils {

	/**
	 * Finds the resource from the class path with the given location using
	 * default ClassLoader.
	 * 
	 * @param location
	 *            The resource location
	 * @return an {@link URL} for reading the resource or null
	 * @see ClassUtils#getDefaultClassLoader()
	 * @see ClassLoader#getResource(String)
	 */
	public static URL getResource(String location) {
		return ClassUtils.getResource(location);
	}

	/**
	 * Returns an input stream for reading the specified resource.
	 * 
	 * @param location
	 *            The resource location
	 * @return An input stream for reading the resource or null
	 * @see ResourceUtils#getResource(String)
	 * @see ClassLoader#getResourceAsStream(String)
	 */
	public static InputStream getResourceStream(String location) {
		final URL url = getResource(location);
		try {
			return url != null ? url.openStream() : null;
		} catch (IOException e) {
			return null;
		}
	}
}

@@ -726,16 +726,69 @@
 ommon;%0A%0A
+import java.io.File;%0Aimport java.io.FileInputStream;%0A
 import j
@@ -855,16 +855,71 @@
 net.URL;
+%0Aimport java.util.Objects;%0Aimport java.util.Properties;
 %0A%0A/**%0A *
@@ -1941,11 +1941,992 @@
 ;%0A%09%09%7D%0A%09%7D
+%0A%0A%09/**%0A%09 * Read %7B@link Properties%7D from the given file.%0A%09 *%0A%09 * @param file%0A%09 *            the properties file url%0A%09 * @return %7B@link Properties%7D%0A%09 * @throws IOException%0A%09 *             if unable to read file%0A%09 */%0A%09public static Properties getProperties(URL file) throws IOException %7B%0A%09%09Objects.requireNonNull(file, %22file cannot be null%22);%0A%09%09final Properties properties = new Properties();%0A%09%09try (InputStream is = file.openStream()) %7B%0A%09%09%09properties.load(is);%0A%09%09%7D%0A%09%09return properties;%0A%09%7D%0A%0A%09/**%0A%09 * Read %7B@link Properties%7D from the given file.%0A%09 *%0A%09 * @param file%0A%09 *            the properties file url%0A%09 * @return %7B@link Properties%7D%0A%09 * @throws IOException%0A%09 *             if unable to read file%0A%09 */%0A%09public static Properties getProperties(File file) throws IOException %7B%0A%09%09Objects.requireNonNull(file, %22file cannot be null%22);%0A%09%09final Properties properties = new Properties();%0A%09%09try (InputStream is = new FileInputStream(file)) %7B%0A%09%09%09properties.load(is);%0A%09%09%7D%0A%09%09return properties;%0A%09%7D
 %0A%7D%0A

Add common resource utilities for reading properties files