FileInputStream and FileNotFound Exception

后端 未结 5 2002
慢半拍i
慢半拍i 2021-01-28 11:05

I am trying to retrieve a jrxml file in a relative path using the following java code:

 String jasperFileName = \"/web/WEB-INF/reports/MemberOrderListReport.jrxm         


        
5条回答
  •  长发绾君心
    2021-01-28 11:45

    You should place 'MemberOrderListReport.jrxml' in classpath, such as it being included in a jar placed in web-inf\lib or as a file in web-inf\classes. The you can read the file using the following code:

     InputStream is=YourClass.class.getClassLoader().getResourceAsStream("MemberOrderListReport.jrxml");
    

提交回复
热议问题