Java tutorial
//package com.java2s; // are made available under the terms of the Eclipse Public License v1.0 import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { private static final String elementDelim = "/"; /** * Converts a path into a <code>List</code> of element names. * * @param childPath a path. e.g. "aaa:bbb/ccc:ddd/eee" * @return a <code>List</code> of element names. * e.g. "aaa:bbb", "ccc:ddd", "eee". */ private static List getElementNames(final String childPath) { List<String> strArray = new ArrayList<>(); if (childPath != null) { StringTokenizer st = new StringTokenizer(childPath, elementDelim); while (st.hasMoreTokens()) { String token = st.nextToken(); if (token.length() > 0) { strArray.add(token); } } } return strArray; } }