Results 1 to 5 of 5
- 01-11-2008, 09:33 AM #1
Senior Member
- Join Date
- Nov 2007
- Posts
- 111
- Rep Power
- 0
Taking input from Properties File
I have written an application which needs input from user. I was thinking about my options. XML is an option but I don't want to use that.
Can I use properties file for the input? Is it a good way of using properties file in Java or it has some other use?
Thanks for looking into this.
- 01-11-2008, 10:10 AM #2
Member
- Join Date
- Jan 2008
- Posts
- 4
- Rep Power
- 0
Usage of property file
You can use the property files when the application needs to get some values which are configured by the users.
For eg, an anti virus application to scan the hard drive in a user defined schedule, user is able to change the schedule interval in a peoperty file as,
SCAN_INTERVAL_IN_HOURS = 10
Here each time the application starts, it will read the value of the key "SCAN_INTERVAL_IN_HOURS".
- 05-06-2008, 04:58 PM #3
Member
- Join Date
- May 2008
- Posts
- 2
- Rep Power
- 0
input from property file
hi can any one help me in hoe to read values from property file
- 05-06-2008, 05:06 PM #4
Example
Java Code:Properties properties = new Properties(); properties.load(new FileInputStream( propertyFilepath ));
Java Code:properties.getProperty(yourKey);
is this what you wanted? :confused:i am the future
- 05-07-2008, 09:30 AM #5
Member
- Join Date
- May 2008
- Posts
- 2
- Rep Power
- 0
hi i write this code and it worked f9
private String getProperty() {
// TODO Auto-generated method stub
Properties properties = new java.util.Properties();
try {
properties.load( ( this.getClass().getClassLoader().getResourceAsStre am( "application.properties" ) ));
}
catch (IOException e) {
e.printStackTrace();
}
return properties.getProperty("SMTP_HOST");
}
Similar Threads
-
Reading a properties file
By peiceonly in forum New To JavaReplies: 7Last Post: 05-06-2010, 05:17 PM -
count character in text file as input file
By aNNuur in forum New To JavaReplies: 7Last Post: 03-25-2010, 04:01 PM -
How to getvalue from properties file into JSP
By jaga in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 04-04-2008, 08:00 AM -
Taking input from console
By Java Tip in forum Java TipReplies: 0Last Post: 11-05-2007, 04:47 PM -
doubt about language .properties file
By tommy in forum Advanced JavaReplies: 1Last Post: 07-31-2007, 02:38 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks