url - Java. Read folder from 'resources' while executing JAR: URI is not hierarchical -


i put folder 'profiles' (contains language profiles, need use when executing jar) 'resources' folder. read write:

url langprofilesurl = classloader.getsystemresource("resources/profiles"); file langprofilesdir = new file(langprofilesurl.touri()); 

it works ok when run in ide: url file:/d:/coding/happystate/bin/resources/profiles

but when execute happystate.jar get:

java.lang.illegalargumentexception:  

where url jar:file:/d:/happystate.jar!/resources/profiles

could please tell me in order read 'profiles' folder correctly? thank much!

use class.getresource() method instead. handles cases whether project on flat filesystem or in jar file or on remote http location. should note approach not allow same things file (actually folder) object.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -