Read Property File in JAVA JAR File:
Did you ever came in a situation, where you exported a java project as a jar file and you got a filenotfound exception ? If yes, then this is not a problem with your code but it is a mechanism in which the normal file reading operation do not work in the java. Alternatively, we should use the below snippet of reading the property file, when you generate a JAR File.
____________________________________________________
Properties props = new Properties();
URL url = ClassLoader.getSystemResource("property file path");
if(url!=null)
props.load(url.openStream());
___________________________
The code above will help you reading a property file in a JAR File.
If you need any urgent assistance on reading-property-file-in-jar-file, kindly email your requirement to us at : info@javagenious.com or Contact-an-Expert. Our experts will try their best to solve your problem.
You can also subscribe to our newsletters on reading-property-file-in-jar-file, to receive updates on reading-property-file-in-jar-file,via email.Enter you email below:
Keyword Tags: reading-property-file-in-jar-file tutorial,reading-property-file-in-jar-file in java,Concepts of reading-property-file-in-jar-file,Java,J2EE,Interview Questions,reading-property-file-in-jar-file Examples
|