Here you can find the source of createPathIterator(String path)
static public Iterator createPathIterator(String path)
//package com.java2s; /******************************************************************************* * Copyright (c) 2003, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w ww .java2s .c om*/ * IBM Corporation - initial API and implementation *******************************************************************************/ import java.util.Iterator; public class Main { /** * Returns an iterator that iterates over the sub nodes of a path. */ static public Iterator createPathIterator(String path) { String tPath = path.startsWith("/") ? path.substring(1) : path; //$NON-NLS-1$ if (tPath.length() == 0) tPath = null; final String aPath = tPath; return new Iterator() { int prevIndex = 0; int curIndex = 0; String pathString = aPath; public boolean hasNext() { return pathString != null && prevIndex != -1; } public Object next() { curIndex = pathString.indexOf('/', prevIndex); String nodeString = null; if (curIndex != -1) nodeString = pathString .substring(prevIndex, curIndex++); else nodeString = pathString.substring(prevIndex); prevIndex = curIndex; return nodeString; } public void remove() { throw new UnsupportedOperationException(); } }; } }