按键遍历ListMultimap

时间:2013-11-24 16:32:20

标签: java guava

stackoverflow社区,我无法设计如何遍历fileToPackageMaping ListMultimap(Google Guava)。

代码:

private static ListMultimap<ListMultimap<String, String>, String> fileToPackageMaping = ArrayListMultimap.create();
for (Map.Entry<ListMultimap<String,String>, Collection<String>> dirMaping : fileToPackageMaping.asMap().entrySet()) {

        ListMultimap<String, String> packageCatalogue = dirMaping.getKey();

        for (String packageName : packageCatalogue.asMap().keySet()) {
            System.out.println("Package :" + packageName);
            System.out.println("Catalogue :" + packageCatalogue.get(packageName));
        }

        Collection<String> urls = dirMaping.getValue();
        for(String url : urls) {
        System.out.println("Url :" + url);
        }
}

packageCatalogue包含相同的键,但具有不同的值,所以我想以这种格式迭代它(我想写出所有特定的键值并在打印出来时):

key1, value1, value2, value3.

key2, value5, value6.

目前输出:

key1, value1

key1, value2

key1, value3

key2, value5

key2, value6

我希望你明白我想做什么..

0 个答案:

没有答案