java配置文件读取

时间:2022-04-27 11:23:59
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

//属性文件操作类
public class ServerConfig {

private static Properties p = new Properties();
static {
try {
p.load(
new FileInputStream("./server.ini"));
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(
"服务器加载配置文件出错!");
}
}

public static String getValue(String key) {
return p.getProperty(key);
}
}

 

server_port=8211
action_server_port
=8212
file_server_port
=8213
output_amr_path
=d:/amr
output_image_path
=d:/image

database.driverClass
=com.microsoft.sqlserver.jdbc.SQLServerDriver
database.url
=jdbc:sqlserver://localhost:1433;DatabaseName=hyhd
database.username=sa
database.password
=