应用程序配置文件app.properties中包含如下一些信息:
name=administor
pwd=554499
port=8000
怎么获取这个文件中的值呢?(最好使用Singleton的方式,有其它方式也行)
哪位兄台知道的话,麻烦进来指点指点!!!
name=administor
pwd=554499
port=8000
怎么获取这个文件中的值呢?(最好使用Singleton的方式,有其它方式也行)
哪位兄台知道的话,麻烦进来指点指点!!!
解决方案 »
- MyEclipse的项目中今天多出了个.idea文件是干嘛用的?
- url 参数问题
- HibernateTemplate除了load,get方法外还有其他方法取数据吗?
- 关于数字概率的问题
- Jacorb Notification Service
- 求助,使用httpclient实现登陆的问题,高手来看看
- 请大侠指点怎么用JSP实现下拉列表的动态方法???
- Install Anywhere 生成exe文件后不能运行的问题
- JDBC链接数据库的问题,出现如下错误 !
- 在一个公司工作半个月了,我是不是能跳啊?
- 请问,在hibernate中,这样的问题怎么办could not locate named parameter
- 关于Struts2拦截器的问题
Properties props = new Properties();
InputStream in = new FileInputStream(new File("app.properties"));
props.load(in);
in.close();
System.out.println("name = "+props.get("name"));
InputStream in = new FileInputStream(new File("app.properties"));
props.load(in);
in.close();
System.out.println("name = "+props.get("name"));
public final static String NAME= "name";
public final static String PWD = "pwd";
public final static String PORT = "port";
public static void init()
{
InputStream inputStream = ClassLoader.getSystemResourceAsStream(APP_CONFIG_FILENAME);
Properties properties = new Properties();
try
{
properties.load(inputStream);
}
catch (IOException e)
{
e.printStackTrace();
}
String name= properties.getProperty(NAME);
String pwd= properties.getProperty(PWD);
String port= properties.getProperty(PORT);
}