I have a Java application that uses SQLite as a Database. I want to execute some setup queries that are stored in a file called "setup.sql".
I call the following code to read the file:
BufferedReader reader = new BufferedReader(new FileReader(Resources.SETUP.file)))
Resources.SETUP.file
is an enum that stores the file paths, in this case to "sql/setup.sql" located in the resources folder of my project.
I use this scheme for other files like images and localization, which works perfectly, like the following example for the logo image (Enum is "images/logo.png"):
Image logoImage = new Image(Resources.LOGO.file);
However with the sql file I always get a FileNotFoundException
.
Am I using the Readers incorrectly?
The following does not work:
getClass().getResource(Resources.SETUP.file); -> InvocationTargetException
getClass().getClassLoader().getResource(Resources.SETUP.file); -> FileNotFoundException