Given I am able to load my mail.properties file such as :
ResourceBundle rb = ResourceBundle.getBundle("META-INF.mail");
System.out.prinltn("subject :" + rb.getString("email.subject")); //output : 'subject : Job Application'
However I am unable to read; in the same method; my mail.properties file as a FileInputStream
. I have tried all these options none of them worked and I am always getting a FileNotFoundException
:
FileInputStream fis = new FileInputStream("META-INF/mail.properties");
FileInputStream fis = new FileInputStream("META-INF//mail.properties");
FileInputStream fis = new FileInputStream("META-INF\\mail.properties");
The folder META-INF exists within a jar that is loaded at build time :
Any help will be more than appreciated.
The problem is FileInputStream()
will look for paths relative to current directory. Since your META-INF
is inside the imported jar, it won't be able to find it.
As per this post, you have following options:
Class.getResourceAsStream
or similarcheck it out for more details.
My question if you are able to load it with ResourceBundle
, why are you trying to reload it in a different way?