I have getSemiFileInfos() in a list and I wanted to use stream and then loop each of element inside. Each element can still use getItem() or getItem2(). I will first create a map for item and item2 in itemMap, then I will store each loop of getSemiFileInfos() as a map into items list.
What I want is to have it in a single line. I am wondering whether is still possible.
private List<Map<String, String>> items;
items = new ArrayList<Map<String, String>>();
Map<String, String> itemMap = new HashMap<String, String>();
file.getFileInfo().getSemiFileInfos().stream().forEach(m->
itemMap.put("item", m.getItem());
itemMap.put("item2", m.getItem2().split(":",1))
);
items.add(mrphMap);