java - getResource() not finding file? -
when trying load file in eclipse file loads fine, when package project .jar file using jar-splice seems application can no longer locate resource files.
here's error thrown when application run
and here method loads files:
public static file loadfile(string path) throws filenotfoundexception { inputstream stream; stream = fileutil.class.getclassloader().getresourceasstream(path); system.out.println("stream = " + stream); //debug purposes file file = new file(fileutil.class.getclassloader().getresource(path).getfile()); if (!file.exists()) { system.err.println("path: " + fileutil.class.getclassloader().getresource(path).getpath()); //also debug purposes throw new filenotfoundexception(); } return file; }
using 2 system.out.printlns it's clear application can't find file based on path, if @ picture path file it's looking located. confused has never happened before, , path it's saying can't find file @ is. ideas anyone?
here method files
here method neither nor can load resources files. impossible. resources not files , not live in file system. must redesign return either url or inputstream, , can both directly class or classloader don't need method @ all.
Comments
Post a Comment