使用J2SE API读取Properties文件的六种方法(3)

2008-02-23 09:36:36来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折


p = JProperties.loadProperties(name, JProperties.BY_CLASSLOADER);
assertEquals(value, p.getProperty(key));

name = "test\\LocalStrings.properties";
p = JProperties.loadProperties(name, JProperties.BY_CLASS);
assertEquals(value, p.getProperty(key));
}

/*
public void testLoadProperties2() throws Exception {
ServletContext context = null;
String path = null;
Properties p = null;
path = "/WEB-INF/classes/LocalStrings.properties";
p = JProperties.loadProperties(context, path);
assertEquals(value, p.getProperty(key));
}
*/
}

properties文件与JPropertiesTest.java文件相同的目录下
LocalStrings.properties文件

# $Id: LocalStrings.properties,v 1.1 2000/08/17 00:57:52 horwat Exp $

# Default localized resources for example servlets
# This locale is en_US

helloworld.title=Hello World!

requestinfo.title=Request Information Example
requestinfo.label.method=Method:
requestinfo.label.requesturi=Request URI:
requestinfo.label.protocol=Protocol:
requestinfo.label.pathinfo=Path Info:
requestinfo.label.remoteaddr=Remote Address:

requestheader.title=Request Header Example

requestparams.title=Request Parameters Example
requestparams.params-in-req=Parameters in this request:
requestparams.no-params=No Parameters, Please enter some
requestparams.firstname=First Name:
requestparams.lastname=Last Name:

cookies.title=Cookies Example
cookies.cookies=Your browser is sending the following cookies:
cookies.no-cookies=Your browser isn't sending any cookies
cookies.make-cookie=Create a cookie to send to your browser
cookies.name=Name:
cookies.value=Value:
cookies.set=You just sent the following cookie to your browser:

sessions.title=Sessions Example
sessions.id=Session ID:
sessions.created=Created:
sessions.lastAccessed=Last Accessed:
sessions.data=The following data is in your session:
sessions.adddata=Add data to your session
sessions.dataname=Name of Session Attribute:
sessions.datavalue=Value of Session Attribute:

上一篇: 反思以前对“多对多”关系处理的设计
下一篇: 从UDDI注册中心查询服务

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:反思以前对“多对多”关系处理的设计

下一篇:java函数传值的一点心得