开发者

Getting the url of a local jasper report (.jrxml) file in java

开发者 https://www.devze.com 2023-01-17 23:58 出处:网络
I\'m using netBeans and I\'m trying to generate a report unsing Jasper Report Can I get the url (of the local jrxml file) of the report

I'm using netBeans and I'm trying to generate a report unsing Jasper Report

Can I get the url (of the local jrxml file) of the report which is stored in the the following directory structure

My_project
   |_build
   |_dist
   |_nbproject
   |_src
     |_my_project
     |_META_IN开发者_高级运维F
     |_report.jrxml
     |_report.jasper

I dont want to add the absolute path to my report file I want java /java classes to do that for me is there any way to get the file name parameter in

JasperDesign jasperDesign = JRXmlLoader.load ("__MY_REPORT_NAME");


You can use :

InputStream in = 
      getClass().getResourceAsStream("/relative/path/to/yourReport.jasper");
JasperDesign jasperDesign = JRXmlLoader.load(in);
0

精彩评论

暂无评论...
验证码 换一张
取 消