John Alexander Betts
John Alexander Betts

Reputation: 5204

Trying to load a file platform independent

I am trying to open a file platform independent in this way:

FileInputStream file = new FileInputStream("/opt/sampleFile.jasper");

In linux all is right but in windows I am getting the following exception:

java.io.FileNotFoundException: \opt\sampleFile.jasper

In windows I am locating this file in c:\opt\

What is wrong?

Upvotes: 0

Views: 92

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533870

What is the default drive for your application? /opt/ will be C:/opt/ on Windows if this is the drive of your current working directory.

Instead of storing data in a system directory like /opt I would use a directory relative to the user's home directory i.e. System.getProperty("user.home")

Upvotes: 3

Related Questions