Java tutorial
//package com.java2s; // Lesser General Public License as published by the Free Software Foundation. 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 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; } }