Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-11-2008, 11:33 AM
Senior Member
 
Join Date: Nov 2007
Posts: 111
bugger is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-11-2008, 12:10 PM
Member
 
Join Date: Jan 2008
Posts: 4
Sreejesh is on a distinguished road
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".
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-06-2008, 06:58 PM
Member
 
Join Date: May 2008
Posts: 2
deenkar1984 is on a distinguished road
input from property file
hi can any one help me in hoe to read values from property file
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-06-2008, 07:06 PM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 187
rjuyal is on a distinguished road
Example
Code:
Properties properties = new Properties(); properties.load(new FileInputStream( propertyFilepath ));
Code:
properties.getProperty(yourKey);

is this what you wanted?
__________________
i am the future
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-07-2008, 11:30 AM
Member
 
Join Date: May 2008
Posts: 2
deenkar1984 is on a distinguished road
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");
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to getvalue from properties file into JSP jaga JavaServer Pages (JSP) and JSTL 1 04-04-2008 10:00 AM
Taking input from console Java Tip Java Tips 0 11-05-2007 06:47 PM
Reading a properties file peiceonly New To Java 5 08-09-2007 09:08 PM
doubt about language .properties file tommy Advanced Java 1 07-31-2007 04:38 PM
count character in text file as input file aNNuur New To Java 0 06-18-2007 08:46 AM


All times are GMT +3. The time now is 02:30 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org