Java Properties Load loadProperties(Class clazz, String name)

Here you can find the source of loadProperties(Class clazz, String name)

Description

load Properties

License

Open Source License

Declaration

public static Properties loadProperties(Class<?> clazz, String name)
            throws IOException 

Method Source Code

//package com.java2s;
/*//from  w  w w  . j a v a  2 s. c o m
 * SK's Minecraft Launcher
 * Copyright (C) 2010-2014 Albert Pham <http://www.sk89q.com> and contributors
 * Please see LICENSE.txt for license information.
 */

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Main {
    public static Properties loadProperties(Class<?> clazz, String name)
            throws IOException {
        Properties prop = new Properties();
        InputStream in = null;
        try {
            in = clazz.getResourceAsStream(name);
            prop.load(in);
        } finally {
            closeQuietly(in);
        }
        return prop;
    }

    public static void closeQuietly(Closeable closeable) {
        try {
            if (closeable != null) {
                closeable.close();
            }
        } catch (IOException e) {
        }
    }
}

Related

  1. loadProperties()
  2. loadProperties()
  3. loadProperties(ByteSource is)
  4. loadProperties(Class clazz, String name)
  5. loadProperties(Class clazz)
  6. loadProperties(Properties p, String progname)
  7. loadProperties(Properties properties, Class clazz, String propDir, String name)
  8. loadProperties(Properties properties, Class baseClass, String... propertiesName)
  9. loadProperties(Properties props, final Class clazz, final String resourceName)