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
Post a Comment