Here you can find the source of parseInitMap(InputStream in, DocumentBuilder builder, Map
private static void parseInitMap(InputStream in, DocumentBuilder builder, Map<String, List<String>> initMap) throws Exception
//package com.java2s; /*/*w ww. j a va 2 s .c om*/ * Copyright (C) 2006-2016 Talend Inc. - www.talend.com * * This source code is available under agreement available at * %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt * * You should have received a copy of the agreement along with this program; if not, write to Talend SA 9 rue Pages * 92150 Suresnes, France */ import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import javax.xml.parsers.DocumentBuilder; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { private static void parseInitMap(InputStream in, DocumentBuilder builder, Map<String, List<String>> initMap) throws Exception { Document doc = builder.parse(in); NodeList nodelist = doc.getElementsByTagName("item"); //$NON-NLS-1$ for (int i = 0; i < nodelist.getLength(); i++) { Node node = nodelist.item(i); NodeList list = node.getChildNodes(); String name = null; for (int j = 0; j < list.getLength(); j++) { Node n = list.item(j); if (n instanceof Element) { if ("name".equals(n.getNodeName())) { //$NON-NLS-1$ name = n.getTextContent(); if (initMap.get(name) == null) { initMap.put(name, new ArrayList<String>()); } } if ("list".equals(n.getNodeName())) { //$NON-NLS-1$ if (n.getTextContent() == null || n.getTextContent().trim().length() == 0) { continue; } List<String> lists = initMap.get(name); String[] arr = n.getTextContent().split(";"); //$NON-NLS-1$ lists.addAll(Arrays.asList(arr)); } } } } } }