package com.ljun.tree.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.junit.Test;
/**
*
* @author 梁军
* @date 2013-9-4
* @projectName recurrence_tree
* @className PropertiesUtil.java
* @description 读取配置文件
*
*/
public class PropertiesUtil {
private static InputStream inputStream = PropertiesUtil.class.getClassLoader().
getResourceAsStream("dataSource.properties");
private static Properties prop = new Properties();
static {
try {
prop.load(inputStream);
} catch (IOException e) {
System.out.println("IOException");
e.printStackTrace();
}
}
public static String getProperty(String key) {
String value = prop.getProperty(key);
return value;
}
@Test
public void test(){
System.out.println(PropertiesUtil.getProperty("tree.datasource.driverClassName"));
}
}
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.junit.Test;
/**
*
* @author 梁军
* @date 2013-9-4
* @projectName recurrence_tree
* @className PropertiesUtil.java
* @description 读取配置文件
*
*/
public class PropertiesUtil {
private static InputStream inputStream = PropertiesUtil.class.getClassLoader().
getResourceAsStream("dataSource.properties");
private static Properties prop = new Properties();
static {
try {
prop.load(inputStream);
} catch (IOException e) {
System.out.println("IOException");
e.printStackTrace();
}
}
public static String getProperty(String key) {
String value = prop.getProperty(key);
return value;
}
@Test
public void test(){
System.out.println(PropertiesUtil.getProperty("tree.datasource.driverClassName"));
}
}