import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Properties;
import com.huawei.ecc.constant.SystemCode;
public class ReadServerProperties {
public static void main(String[] args) {
System.out.println("*********************");
String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
try {
path = URLDecoder.decode(path, "utf-8");
System.out.println("path = " + path);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Properties properties = new Properties();
String filePath = path + "/server.properties";
File file = new File(filePath);
if (file.exists()){
InputStream is = null;
try
{
is = new FileInputStream(file);
properties.load(is);
String property = new String(
properties.getProperty("dataSource.driverClassName").getBytes("ISO-8859-1"),
"utf-8");
System.out.println("properties = " + property);
}catch(Exception e){
e.printStackTrace();
}
}
}
}
#DataBase
dataSource.driverClassName=oracle.jdbc.driver.OracleDriver
dataSource.url=jdbc:oracle:thin:@。。。。。
dataSource.username=。。。。
dataSource.password=。。。