Java tutorial
//package com.java2s; /*----------------------------------------------------------------------- * Copyright (C) 2001 Green Light District Team, Utrecht University * * This program (Green Light District) is free software. * You may redistribute it and/or modify it under the terms * of the GNU General Public License as published by * the Free Software Foundation (version 2 or later). * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * See the documentation of Green Light District for further information. *------------------------------------------------------------------------*/ import java.util.StringTokenizer; public class Main { /** * Calculates the level of a XML path name * * @param fullName The path name * @return the level */ public static int getLevel(String fullName) { return (new StringTokenizer(fullName, ".")).countTokens(); } }