code: private int getLastFileSeparator(String file) {
          if (file.contains("*") || file.contains("?")) {
              int p1 = file.indexOf('*');
              int p2 = file.indexOf('?');
              p1 = p1 > 0 ? p1 : file.length();
              p2 = p2 > 0 ? p2 : file.length();
              int pos = p1 < p2 ? p1 : p2;
              pos = file.lastIndexOf('/', pos);
              return pos;
          } else {
              return file.lastIndexOf('/');
          }
      }
docs: Returns the position of the last file separator.
  
  @param file a file path
  @return the position of the last file separator