【发布时间】:2015-05-05 10:54:06
【问题描述】:
我想从列表中的数组中获取一个值。每个列表值都包含一个数组,我想从该数组中获取一个单值。
Mail.java
properties = new Properties("server_url.properties");
dataAccess = new DataAccess(properties);
List<Map<String,String>> resp = new ArrayList<Map<String,String>>() ;
List<Map<String,String>> obj = new ArrayList<Map<String,String>>() ;
resp=dataAccess.getApplications();
obj=dataAccess.getServers();
//System.out.println(resp.get(0));
MailServer sender = new MailServer(Constants.setFrom, Constants.setPassword);
try {
sender.sendMail("Demo Apps & Server Status","The Following Applications are DOWN" + '\n'+
'\n' + resp.get(0) + '\n'+
'\n'+ "The Following servers are DOWN" +'\n'
+ '\n' + obj.get(2)
,Constants.setFrom,Constants.emailTO);
}
catch (Exception e) {
e.printStackTrace();
System.out.println("Email was not sent...");
}
System.out.println("Email Sent Succesfully...");
}
如果我运行上面的代码,我会得到以下列表值
输出
{DataBase=Oracle, Links=192.168.215.158:1521:sscdb01, status=UP, 192.168.215.158:151:sscdb01=UP, name=Claim Status, WebServices=}
{Links=https://mobile.infotech.com:8090, status=UP, ssl_exp_date=Mon Apr 18 14:42:45 IST 2016, https://mobile.infotech.com:8090=UP, name=com}
从上面的值我只想得到两个值 - name 和 Status 值而不从列表值中获取所有值
【问题讨论】:
标签: java arrays list collections