Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static int getDepth(String value) { int len = value.length(); int levels = 0; char[] chars = new char[len]; value.getChars(0, len, chars, 0); for (int i = 0; i < len; i++) { if (chars[i] == '/' && (i + 1 < len) && chars[i + 1] != '/') { levels++; } } return levels; } }