private String nameWithoutTrailingSeparator(Path file) {
    String fileName = file.getFileName().toString();
    int trailingSlash = fileName.indexOf('/');
    if (trailingSlash != -1) {
      fileName = fileName.substring(0, trailingSlash);
    }
    return fileName;
  }
private String nameWithoutTrailingSeparator(Path file) {
    String fileName = file.getFileName().toString();
    int trailingSlash = fileName.indexOf('/');
    if (trailingSlash != -1) {
      fileName = fileName.substring(0, trailingSlash);
    }
    return fileName;
  }
private String nameWithoutTrailingSeparator ( Path file ) { String fileName = file . getFileName ( ) . toString ( ) ; int trailingSlash = fileName . indexOf ( ' ' ) ; if ( trailingSlash != - 1 ) { fileName = fileName . substring ( 0 , trailingSlash ) ; } return fileName ; }
It sure seems like a bug that Path#getFileName() returns "name/" for paths inside a jar, but
"name" for paths on a regular filesystem. It's always a normal slash, even on Windows. :-p
It sure seems like a bug that Path#getFileName () returns name / for paths inside a jar but name for paths on a regular filesystem . It s always a normal slash even on Windows . : - p