code: private void check( String pathName )
      {
          for ( char c : pathName.toCharArray() ) {
              if ( c < 32 || FORBIDDEN_CHAR == c ) {
                  throw new IllegalArgumentException( "Pathname contains invalid char " + c + " : " + pathName );
              }
          }
          // Check each component :
          for ( String comp : pathName.split( "/" ) ) {
              if ( !comp.trim().equals( comp ) ) {
                  throw new IllegalArgumentException( "Pathname contains leading or trailing spaces : " + pathName );
              }
          }
      }
docs: Check pathname is valid
  
  @param pathName