/*
为了更大的灵活性,当构造一个属性(Properties)对象时,指定一个默认的属性列表。如果在主列表中没有发现期望的关键字,将会搜索默认列表。
*/
//Use a default property list.
import java.util.*;
class PropDemoDef{
public static void main(String[] args)
{
Properties defList = new Properties();
defList.put("JiLin","ChangChun");
defList.put("ShanDong","JiNan");
Properties capitals = new Properties(defList);
Set provinces;
String str;
capitals.put("JiangSu","NanJing");
capitals.put("LiaoNing","ShenYang");
capitals.put("ShanXi","XiAn");
capitals.put("HeBei","ShiJiaZhuang");
//show all provinces and captials in hashtable
provinces = capitals.keySet(); //get set-view of keys
Iterator i = provinces.iterator();
while(i.hasNext()){
str = (String)i.next();
System.out.println("The captial of " + str + " is " + capitals.getProperty(str) + " .");
}
System.out.println();
//JiLin will now be found in the default list.
str = capitals.getProperty("JiLin");
System.out.println("The captial of JiLin is " + str + " .");
}
}
分享到:
相关推荐
在这个示例中,日志级别被设置为DEBUG,所有日志信息都会被写入到指定路径的`logfile.log`中,并按照设定的模式显示日期、优先级、类名、行号和消息。 **整合过程**: 1. 将`log4j-1.2.16.jar`和`slf4j-api-1.6.1....
apache+tomcat集群配置 tomcat 中workers.properties配置说明
# log4j.properties 示例 log4j.rootLogger=INFO, Console, File log4j.appender.Console=org.apache.log4j.ConsoleAppender log4j.appender.Console.Target=System.out log4j.appender.Console.layout=org.apache....
# application.properties 示例 spring.datasource.url=jdbc:mysql://localhost:3306/testdb?useSSL=false&serverTimezone=UTC spring.datasource.username=root spring.datasource.password=root spring.datasource...
本文将详细介绍多种读取Properties文件的方法,并提供相关的代码示例。 1. **使用Properties类加载文件** 最常用的方式是通过`java.util.Properties`类来读取`.properties`文件。以下是一个简单的示例: ```java ...
# log4j.properties 示例 log4j.rootLogger=DEBUG, stdout, FILE log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4...
# application.properties 示例 fastdfstracker.server=192.168.1.100 fastdfstracker.port=22122 # 或者在 YAML 文件中 fastdfs: tracker: server: 192.168.1.100 port: 22122 ``` 接下来,创建一个FastDFS的...
# application.properties 示例 mybatis.mapper-locations=classpath:mapper/*.xml mybatis.type-aliases-package=com.example.entity ``` 3. **创建数据库连接配置**:Spring Boot支持多种数据库连接池,如...
# application.properties 示例 logging.level.root=INFO logging.file.name=logs/app.log ``` 在上面的例子中,根日志级别被设置为INFO,日志将会输出到名为`app.log`的文件中。如果你使用的是YAML格式,配置将...
# application.properties 示例 spring.servlet.multipart.enabled=true spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-request-size=10MB ``` 或者 ```yaml # application.yml 示例...
# application.properties 示例 mybatis-plus.global-config.db-config.id-type=AUTO mybatis-plus.global-config.db-config.logic-delete-value=1 mybatis-plus.global-config.db-config.logic-not-delete-value=0 ...
# application.properties 示例 spring.redis.host=localhost spring.redis.port=6379 spring.redis.password= spring.redis.database=0 spring.redis.jedis.pool.max-active=8 spring.redis.jedis.pool.max-idle=8 ...
# application.properties 示例 spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 spring.rabbitmq.username=guest spring.rabbitmq.password=guest ``` 或者 ```yaml # application.yml 示例 spring: ...
# application.properties 示例 spring.mail.host=smtp.example.com spring.mail.port=587 spring.mail.username=your-email@example.com spring.mail.password=your-password spring.mail.properties.mail.smtp....
# application.properties 示例 spring.datasource.primary.url=jdbc:mysql://localhost:3306/main_db spring.datasource.primary.username=root spring.datasource.primary.password=root spring.datasource....
# application.properties 示例 pagehelper.helperDialect=mysql pagehelper.reasonable=true pagehelper.supportMethodsArguments=true pagehelper.params=count=countSql ``` - **Mapper接口及XML文件**:...
本文将通过两个示例详细解析如何使用`Properties`来处理显卡的AAPL,ig-platform-id和framebuffer参数,以解决特定显卡在黑苹果系统中的显示问题。 首先,了解`AAPL,ig-platform-id`和`device-id`是非常重要的。这两...
# application.properties 示例 spring.datasource.type=com.alibaba.oceanbase.jdbc.OBDriverDataSource spring.datasource.ob.address-list=127.0.0.1:2882 spring.datasource.ob.user=root spring.datasource.ob....
# application.properties 示例 spring.redis.host=127.0.0.1 spring.redis.port=6379 ``` 或者 ```yaml # application.yml 示例 spring: redis: host: 127.0.0.1 port: 6379 ``` 这些配置会告诉Spring Boot...