private Path getPath ( String fileName ) throws IOException , URISyntaxException { Path path ; URL url = getClass ( ) . getClassLoader ( ) . getResource ( fileName ) ; if ( url == null ) { throw new IOException ( String . format ( "File %s is not existing" , fileName ) ) ; } URI uri = url . toURI ( ) ; Map < String , String > env = new HashMap <> ( ) ; if ( uri . toString ( ) . contains ( "!" ) ) { String [ ] parts = uri . toString ( ) . split ( "!" ) ; if ( fs == null ) { fs = FileSystems . newFileSystem ( URI . create ( parts [ 0 ] ) , env ) ; } path = fs . getPath ( parts [ 1 ] ) ; } else { path = Paths . get ( uri ) ; } return path ; }
A get a java . nio . file . Path object from a file name .