public static String ensureNotEndingSlash(String path){
  final int length=path.length();
  return path.charAt(length - 1) == '/' ? path.substring(0,length - 1) : path;
}

public static String ensureNotEndingSlash ( String path ) { final int length = path . length ( ) ; return path . charAt ( length - 1 ) == '/' ? path . substring ( 0 , length - 1 ) : path ; }
ensures that a path does not end with a slash . may return an empty string .
