打印System.getProperties的属性值
来源:互联网 发布:淘宝女装文案模板 编辑:程序博客网 时间:2024/06/05 19:43
import java.util.*;public class MyTest{ /** * Create the panel. */ public MyTest() { java.util.Properties pp = System.getProperties(); java.util.Enumeration en = pp.propertyNames(); TreeMap<String, String> map = new TreeMap<String, String>(new Comparator<String>() { /* * int compare(Object o1, Object o2) 返回一个基本类型的整型, * 返回负数表示:o1 小于o2, * 返回0 表示:o1和o2相等, * 返回正数表示:o1大于o2。 */ public int compare(String o1, String o2) { //指定排序器按照升序排列 a-z return o1.compareTo(o2); } }); while (en.hasMoreElements()) { String elm = (String) en.nextElement(); map.put(elm, encodeHTML(pp.getProperty(elm))); } StringBuffer buffer = new StringBuffer(); buffer.append("<Table>"); int i = 0; Set<Map.Entry<String, String>> entries = map.entrySet(); Iterator<Map.Entry<String, String>> it = entries.iterator(); while (it.hasNext()) { String color = i % 2 == 1 ? "#ddd" : ""; buffer.append("<tr style='background-color:" + color + "'><td style='color:blue'>"); Map.Entry<String, String> next = it.next(); buffer.append(next.getKey()); buffer.append("</td><td>"); buffer.append(next.getValue()); buffer.append("</td></tr>"); i++; } buffer.append("</Table>"); System.out.println(buffer.toString()); } public static String encodeHTML(String str) { String retStr = ""; retStr = str.replaceAll(" ", " "); retStr = str.replaceAll("<", "<"); retStr = str.replaceAll(">", ">"); retStr = str.replaceAll("\n", "<br/>"); retStr = str.replaceAll("\n\r", "<br>"); str.replaceAll("&", "&"); return retStr; } public static void main(String[] args) { MyTest m = new MyTest(); }}
0 0
- 打印System.getProperties的属性值
- 打印System.getProperties的属性值
- 打印系统属性System.getProperties()
- java(10)------System.getProperties()打印系统属性
- java的System.getProperties属性
- System.getProperties() 得到系统属性
- System.getProperties中的所有属性
- System.getProperties()系統属性
- System.getProperties()可以获得的参数
- java System.getProperties() 的用法
- System.getProperties都返回什么系统属性
- System.getProperties("user.dir")获得系统属性
- System.getProperties()获得系统属性s
- System.getProperties()
- System.getProperties()(
- System.getProperties();
- System.getProperties
- System.getProperties("?")
- Android生命周期函数(干货)
- 每天进步一点点
- 黑马程序员-银行业务调度
- 关于毛刺
- 找出最小的100万数字
- 打印System.getProperties的属性值
- C语言数据类型占字节数
- Deeplearning学习之Theano(1)--保存参数
- uboot启动过程完全分析
- 第一次实验:八皇后及N皇后问题
- openwrt+rt5350 运行失败问题 DTB has bad magic(成都康亚姆网络科技有限公司)
- Remove Element
- HTTP请求格式和响应格式
- Matlab绘图-很详细,很全面