嗨,我想以表格格式打印 hashmap 的数据。下面是我在 hashmap 中插入数据的代码。
String foldername = item.getParent().substring(item.getParent().lastIndexOf("/") + 1);
statusname = foldername + "\t" + _DeployResult.ServerIP + "\t" + _DeployResult.ServerType;
if (!Prdeploy.statusmap.containsKey(statusname)) {
Prdeploy.statusmap.put(statusname, 0);
}
以下是为打印日志文件中的数据而编写的代码:
logger.info("****************Summary Report****************");
logger.info("Folder\tServer\tType\tFailed");
for (String name: statusmap.keySet()){
String key =name.toString();
String value = statusmap.get(name).toString();
System.out.println(key + " " + value);
logger.info(key + "\t" + value);
}
logger.info("**********************************************");
在这里我得到上面的输出如下:
****************Summary Report****************
Folder Server Type Failed
180_Perl_Scripts 10.5.50.195 SS 0
050_Images 10.5.50.195 SS 0
020_XSL 10.5.50.195 SS 0
srf 10.5.50.195 SS 0
030_XSLT 10.5.50.195 SS 0
bscript 10.5.50.195 SS 0
bscript 10.5.50.195 WS 1
010_StyleSheets 10.5.50.195 SS 0
040_WebTemplates 10.5.50.195 SS 0
050_Images 10.5.50.195 WS 0
060_js_Files 10.5.50.195 SS 0
010_StyleSheets 10.5.50.195 WS 0
**********************************************
但我希望我的输出如下:
****************Summary Report****************
Folder Server Type Failed
180_Perl_Scripts 10.5.50.195 SS 0
050_Images 10.5.50.195 SS 0
020_XSL 10.5.50.195 SS 0
srf 10.5.50.195 SS 0
030_XSLT 10.5.50.195 SS 0
bscript 10.5.50.195 SS 0
bscript 10.5.50.195 WS 1
010_StyleSheets 10.5.50.195 SS 0
040_WebTemplates 10.5.50.195 SS 0
050_Images 10.5.50.195 WS 0
060_js_Files 10.5.50.195 SS 0
010_StyleSheets 10.5.50.195 WS 0
**********************************************
在这里,我无法放置确切的模式。但我只是希望它变成表格格式。结构良好。有没有办法做到这一点?请在这里帮助我!