public static String removeIndexFromPath(String path)
   {
      if (path.endsWith("]"))
      {
         int index = path.lastIndexOf('[');
         if (index != -1)
         {
            return path.substring(0, index);
         }
      }
      return path;
   }
public static String removeIndexFromPath ( String path ) { if ( path . endsWith ( "]" ) ) { int index = path . lastIndexOf ( '[' ) ; if ( index != - 1 ) { return path . substring ( 0 , index ) ; } } return path ; }
Removes the index from the path if it has an index defined