日期:2014-05-20 浏览次数:20879 次
package Test;
import java.util.*;
public class HashMapTest {
public static void main(String[] args)
{
TreeMap<String,TreeMap<String,String[]>> map = new TreeMap<String,TreeMap<String,String[]>>();
//省份ID
//String provId="811";
//省份文件列表
String file1 = "12345678979.dat";
String file2 = "22345678989.dat";
String file3 = "32345678999.dat";
//省份文件列表对应的上传用户名以及密码
String a1[] = new String[]{"user1","23456"};
String a2[] = new String[]{"user2","34567"};
String a3[] = new String[]{"user3","45678"};
//Map存储 key:文件名 value:用户名及密码 length=2 array[0]="username",array[1]="password"
TreeMap<String,String[]> map1 = new TreeMap<String,String[]> ();
map1.put(file1, a1);
map1.put(file2, a2);
map1.put(file3, a3);
//Map存储 Key:省份ID value: 存储map1
map.put("811", map1);//.put("811", map1);
Iterator<String> it = map.keySet().iterator();
while(it.hasNext())
{
String provId = it.next();
System.out.println(provId);
Map<String,String[]> value = map.get(provId);
for(Map.Entry<String, String[]> me : value.entrySet())
{
String fileName = me.getKey();
String[] user_password = me.getValue();
System.out.println(fileName+" "+Arrays.toString(user_password));
}
}
}
}