Lina
Lina

Reputation: 315

File Not found exception error in Inputstream Function

I am passing URL as string in FileInputstream function but it is giving me file not found exception error and when I run same URL on browser it is working fine. Below I am mentioning my code.

 InputStream input = new FileInputStream(new File("http://192.168.0.107:4911//CustomReports//report23.jrxml"));
JasperDesign jasperDesign = JRXmlLoader.load(input);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

Kindly help me out Thanks

Upvotes: 0

Views: 183

Answers (2)

davidxxx
davidxxx

Reputation: 131396

The File(String) constructor is not designed to be used with an URL but with a file from a file system.

You could use the File(URI) constructor to achieve your need.

Or more simply, you could create your URL with the URL class and invoke the openStream() method to open a connection to this URL and returns an InputStream for reading from that connection.

InputStream input = new URL("http://192.168.0.107:4911//CustomReports//report23.jrxml").openStream();

Upvotes: 1

Mike Adamenko
Mike Adamenko

Reputation: 3002

Use

InputStream input = new URL("http://192.168.0.107:4911//CustomReports//report23.jrxml").openStream();

Upvotes: 0

Related Questions