日期:2014-05-20 浏览次数:20724 次
String str="SRC:778899AABBCC\nIP:192.168.100.100\nPORT:55055\nDEST:001122334455\n201202271500123000";
String[] strs = str.split("\n");
Map<String,String> hashmap = new HashMap<String, String>();
for(String s : strs)
{
String[] splits = s.split(":");
if(splits != null && splits.length > 1)
{
hashmap.put(splits[0], splits[1]);
}
}
for(Map.Entry<String, String> ent : hashmap.entrySet())
{
System.out.println(ent.getValue());
}
System.out.println(hashmap.get("IP"));
System.out.println(hashmap.get("PORT"));