PropertiesUtil

PropertiesUtil

package com.test.propertise;

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

import org.junit.Test;

public class PropertiesUtil {
    private static Properties pro;
    static{
        pro = new Properties();

        try {
            pro.load(PropertiesUtil.class.getResourceAsStream("/com/test/propertise/app.properties"));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    public static String Get_By_Key(String key) {

        return pro.getProperty(key);
    }

}

app.properties

key=123456789
key2=woshishui
key3=hello world

你可能感兴趣的:(PropertiesUtil)