ChinaUnix.net
相关文章推荐:

spring 读取properties

要在spring 中配置参数 如   jdbc.driverClassName=org.hsqldb.jdbcDriver   jdbc.url=jdbc:hsqldb:hsql://localhost:9002   jdbc.username=sa   jdbc.password= 必须在配置加入 org.springframework.beans.factory.config.PropertyPlaceholderConfigurer 用来读取相应的properties 如               WEB-INF/jdbc.properties             本文来自ChinaUnix博客,如果查...

by zuomo - Java文档中心 - 2008-04-22 10:57:48 阅读(675) 回复(0)

相关讨论

我有一个.properties file.文件格式如下: userid=test1 password=test2 path=c:\test .... 我应该如何读取这个文件,将test1赋值给变量$userid, 将test2赋值给变量$pwd, 将c:\test赋值给变量$path. 另外一个文件格式如下: version=r10.03.00.00|r10.04.00.00|r10.05.00.10... 我应该如何读取这个文件,将r10.03.00.00赋值给变量$v1, 将r10.04.00.00赋值给变量$v2, 将r10.05.00.10赋值给变量$v3.......... 谢谢大家帮忙 :(

by geoffrey - Shell - 2003-07-25 15:29:29 阅读(1288) 回复(6)

public String getPara(String ParaName) { FileName = "../../DBConfig.property"; properties prop = new properties(); try { InputStream is = getClass().getResourceAsStream(FileName); prop.load(is); if(is!=null) is.close(); } catch(Exception e) { return "Error!"; } return prop.ge...

by felixzxh - Java - 2009-03-22 10:34:12 阅读(1884) 回复(6)

1、使用java.util.properties类的load()方法 例: InputStream in = lnew BufferedInputStream(new FileInputStream(name)); properties p = new properties(); p.load(in); 2、使用java.util.ResourceBundle类的getBundle()方法 例: ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault() ); 3、使用java.util.PropertyResourceBundle类的构造函数 例: InputStream in = new BufferedInputStream(new ...

by nijie - Java文档中心 - 2006-03-27 16:14:36 阅读(356) 回复(0)

在我们平时写程序的时候,有些参数是经常改变的,而这种改变不是我们预知的。比如说我们开发了一个操作数据库的模块,在开发的时候我们连接本地的数据库那么 IP ,数据库名称,表名称,数据库主机等信息是我们本地的,要使得这个操作数据的模块具有通用性,那么以上信息就不能写死在程序里。通常我们的做法是用配置文件来解决。 各种语言都有自己所支持的配置文件类型。比如 Python ,他支持 .ini 文件。因为他内部有一个 ConfigP...

by hkebao - Java文档中心 - 2009-09-18 13:36:29 阅读(1097) 回复(0)

在我们平时写程序的时候,有些参数是经常改变的,而这种改变不是我们预知的。比如说我们开发了一个操作数据库的模块,在开发的时候我们连接本地的数据库那么 IP ,数据库名称,表名称,数据库主机等信息是我们本地的,要使得这个操作数据的模块具有通用性,那么以上信息就不能写死在程序里。通常我们的做法是用配置文件来解决。   各种语言都有自己所支持的配置文件类型。比如 Python ,他支持 ....

by springdew - Java文档中心 - 2008-11-30 22:20:25 阅读(619) 回复(0)

1。使用java.util.properties类的load()方法示例:InputStreamin=lnewBufferedInputStream(newFileInputStream(name));propertiesp=newproperties();p.load(in);   2。使用java.util.ResourceBundle类的getBundle()方法示例:ResourceBundlerb=ResourceBundle.getBundle(name,Locale.getDefault());   3。使用java.util.PropertyResourceBundle类的构造函数示例:InputStreamin=newBufferedInputStream(newFileInputStream(nam...

by gongtao200118 - Java文档中心 - 2006-10-26 00:30:59 阅读(244) 回复(0)

spring中,使用PropertyPlaceholderConfigurer和PropertyOverrideConfigurer可以在XML配置文件中加入外部属性文件 但使用这种方式,有一些需要注意的地方 1.首先在主类中,需要使用ClassPathXmlApplicationContext来读取spring配置xml文件 如: ApplicationContext context = new ClassPathXmlApplicationContext("example4/appcontext.xml"); HelloWorld hw = (HelloWorld)context.getBean("fileHelloWorld"); log.info(hw.get...

by peitomb - Java文档中心 - 2008-07-05 21:25:14 阅读(760) 回复(0)

1. jdbc.properties database.url=jdbc:mysql://localhost/smapledatabase.driver=org.gjt.mm.mysql.Driverdatabase.user=rootdatabase.password=star1xing 2.conf.xml com/starxing/test/jdbc.properties ${database.url} ${database.driver} ${database.user} $...

by jplfll - Java文档中心 - 2007-08-13 09:30:37 阅读(379) 回复(0)

1. jdbc.properties database.url=jdbc:mysql://localhost/smapledatabase.driver=org.gjt.mm.mysql.Driverdatabase.user=rootdatabase.password=star1xing 2.conf.xml com/starxing/test/jdbc.properties ${database.url} ${database.driver} ${database.user} $...

by starxing - Java文档中心 - 2007-03-19 16:02:10 阅读(366) 回复(0)

 使用J2SE API读取properties文件的六种方法   1。使用java.util.properties类的load()方法   示例: InputStream in = lnew BufferedInputStream(new FileInputStream(name));   properties p = new properties();   p.load(in);   2。使用java.util.ResourceBundle类的getBundle()方法   示例: ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault());   3。使用java.util.PropertyRe...

by 杨竹青 - OpenAPI - 2008-07-23 11:40:31 阅读(1569) 回复(0)