简体   繁体   中英

Unable to load XSL file from JAR file

I have a java file which uses XSL file to perform transformation. Code used is:

FileInputStream inXLSFile = new FileInputStream("ListApi.xsl");
TransformerFactory factory = TransformerFactory.newInstance(); StreamSource xslStream = new StreamSource(inXLSFile); After this a jar file is generated. from the jar file I am not able to use the XSL. It says 'File not found'. Please give pointers.

change

FileInputStream inXLSFile = new FileInputStream("ListApi.xsl");

to

InputStream inXLSFile = this.getClass().getResourceAsStream("ListApi.xsl");

for more information read about how do I load a file from a jar?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM