import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set; public class PropertiesDemo {
public static void main(String[] args) {
Properties properties = new Properties();
properties.put("zhangsan", "23");
properties.put("lisi", "25");
properties.put("wangwu", "21");
properties.put("zhaoliu", "27");
Set<String> names = properties.stringPropertyNames();
//使用高级for遍历
for(String name : names) {
String value = properties.getProperty(name);
System.out.println(name + " = " + value);
}
//使用迭代器遍历
Iterator<String> iterable = names.iterator();
while(iterable.hasNext()){
String key = iterable.next();
String value = properties.getProperty(key);
System.out.println(key +" = " + value);
}
//使用枚举遍历
Enumeration<String> enumeration = (Enumeration<String>)properties.propertyNames();
while(enumeration.hasMoreElements()) {
String key = enumeration.nextElement();
String value = properties.getProperty(key);
System.out.println(key + " = " + value);
}
}
}

最新文章

  1. 100803C
  2. 9.2---机器人走方格(CC150)
  3. Zookeeper 分布式环境搭建
  4. Autoprefixer处理CSS3属性前缀
  5. shell &amp;&amp; 和 || 的短路使用
  6. 湖大 11404 manacher
  7. iOS UITabBarItem 选中图的颜色,设置UIimage的渲染模式
  8. iOS图片压缩
  9. (转)Div+CSS布局入门
  10. USB枚举过程的详细流程
  11. Java 之 反射
  12. 【滚动数组】【状压dp】Gym - 100956F - Colored Path
  13. Xshell 5 配置上传下载命令
  14. tkinter中树状结构的建立(十四)
  15. vo类,model类,dto类的作用及划分
  16. python利用xlrd读取excel文件始终报错原因
  17. Java常用的经典排序算法:冒泡排序与选择排序
  18. [翻译] 初看 ASP.NET Core 3.0 即将到来的变化
  19. Linux和进程内存模型
  20. Java中 System.arraycopy() 和 Arrays.copyOf()方法

热门文章

  1. matlab练习程序(三角形外接圆)
  2. IIS并发连接数限制
  3. v1.0.2-2017.04.26
  4. TP5:隐藏inde.php文件
  5. zt 设计模式六大原则(3):依赖倒置原则
  6. good pics
  7. (转)浅谈PostgreSQL的索引
  8. UVa 10048 - Audiophobia(Floyd变形)
  9. HDU 6395 Sequence 【矩阵快速幂 &amp;&amp; 暴力】
  10. nssm 在windows上部署服务