Java access files in jar causes java.nio.file.FileSystemNotFoundException -


while trying copy files in jar file temp directory java app, following exception thrown:

java.nio.file.filesystemnotfoundexception     @ com.sun.nio.zipfs.zipfilesystemprovider.getfilesystem(zipfilesystemprovider.java:171)     @ com.sun.nio.zipfs.zipfilesystemprovider.getpath(zipfilesystemprovider.java:157)     @ java.nio.file.paths.get(unknown source)     @ com.sora.util.walltoggle.pro.webviewpresentation.setuptempfiles(webviewpresentation.java:83)    .... 

and small part of setuptempfiles(with line numbers):

81. uri uri = getclass().getresource("/webviewpresentation").touri(); //prints: uri->jar:file:/c:/users/tom/dropbox/walltogglepro.jar!/webviewpresentation 82. system.out.println("uri->" + uri ); 83. path source = paths.get(uri); 

the webviewpresentation directory resides in root directory of jar:

enter image description here

this problem exits when package app jar, debugging in eclipse has no problems. suspect has bug i'm not sure how correct problem.

any helps appreciated

if matters:

i'm on java 8 build 1.8.0-b132

windows 7 ult. x64

a filesystemnotfoundexception means file system cannot created automatically; , have not created here.

given uri, should split against !, open filesystem using part before , path part after !:

final map<string, string> env = new hashmap<>(); final string[] array = uri.tostring().split("!"); final filesystem fs = filesystems.newfilesystem(uri.create(array[0]), env); final path path = fs.getpath(array[1]); 

note should .close() filesystem once you're done it.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -