Reputation: 5204
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
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