public int dirDepth(final File path) {
		final String stringPath = path.getPath();
		return stringPath.length() - stringPath.replaceAll("[/\\\\]", "").length();
	}
public int dirDepth ( final File path ) { final String stringPath = path . getPath ( ) ; return stringPath . length ( ) - stringPath . replaceAll ( "[/\\\\]" , "" ) . length ( ) ; }
Counts the number of directories in a given path.

@param path the path to analyze
@return number of directories