String fileName = "XSLT/Rules.xsl";
ClassLoader classLoader = new Myclass().getClass().getClassLoader();
File file = new File(classLoader.getResource(fileName).getFile());
In this above code, Eclipse its working fine. But build the jar it's not working. Kindly give the solution.
Thanks for advance.
Is XSLT/Rules.xsl included in your JAR? If so, you need to access the file as a resource. You can get an InputStream with:
InputStream in = classLoader.getResourceAsStream(fileName);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.