读取 jar 文件中的 xslt
Read xslt inside jar file
String fileName = "XSLT/Rules.xsl";
ClassLoader classLoader = new Myclass().getClass().getClassLoader();
File file = new File(classLoader.getResource(fileName).getFile());
在上面的代码中,Eclipse 工作正常。但是构建它不起作用的罐子。请给出解决方案。
感谢提前。
XSLT/Rules.xsl 是否包含在您的 JAR 中?如果是这样,您需要将该文件作为资源进行访问。您可以通过以下方式获得 InputStream:
InputStream in = classLoader.getResourceAsStream(fileName);
String fileName = "XSLT/Rules.xsl";
ClassLoader classLoader = new Myclass().getClass().getClassLoader();
File file = new File(classLoader.getResource(fileName).getFile());
在上面的代码中,Eclipse 工作正常。但是构建它不起作用的罐子。请给出解决方案。
感谢提前。
XSLT/Rules.xsl 是否包含在您的 JAR 中?如果是这样,您需要将该文件作为资源进行访问。您可以通过以下方式获得 InputStream:
InputStream in = classLoader.getResourceAsStream(fileName);