Results 1 to 3 of 3
Thread: Reading properties file
- 01-31-2011, 01:52 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 85
- Rep Power
- 0
Reading properties file
In my java app there is a code which reads the properties file from src/main/resources folder.
Now I need to create a jar file and also remove the properties file from src/main/resources folder and place it outside the jar file(in the same location as jar file) so that data inside it can be changed easily in future.Java Code:@Component("mailerProperties") public class MailerProperties { private static Properties properties; public MailerProperties() { properties = new Properties(); InputStream inStream; try { inStream = (new ClassPathResource("mailer.properties")).getInputStream(); properties.load(inStream); } catch (IOException e) { e.printStackTrace(); } } public String getValue(String key) { return properties.getProperty(key); } }
Question: Currently it uses ClassPathResource("mailer.properties") to read the prop file. What change I need to make to read it from outside the jar file
- 01-31-2011, 02:24 PM #2
- 01-31-2011, 04:41 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
Reading a properties file
By peiceonly in forum New To JavaReplies: 7Last Post: 05-06-2010, 05:17 PM -
Unable to access velocity.properties file from jar file
By mjwoodford in forum New To JavaReplies: 0Last Post: 10-09-2009, 01:46 PM -
Weird path problem when reading properties file
By jerry_popperq in forum New To JavaReplies: 0Last Post: 03-18-2009, 03:32 PM -
Reading a properties file using resource bundle.
By rudrakanth in forum New To JavaReplies: 1Last Post: 02-27-2009, 12:23 PM -
Reading web applicaiton properties from JSP/Servlet
By Java Tip in forum Java TipReplies: 0Last Post: 01-30-2008, 09:56 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks