?
Solved

Reading property file

Posted on 2006-07-13
5
Medium Priority
?
239 Views
Last Modified: 2010-03-31
Hello
I have a property file:

PROP FILE:
Strength = Medium
Day = Thursday

------
I used the following code to read the property file
Properties props = new Properties();
            props.load( fis= new FileInputStream (new File ("file.properties")) );
---------
I just need to check if the "Strength" attribute in properties file is equal to "Medium" (java) and "Day" is equal to "Thursday", How do I check this using java code.

Thank you (Urgent response requested:)            
0
Comment
Question by:atwork2003
  • 3
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17102585
if ("Medium".equals(props.getProperty("Strength")) {
}
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 17102591
Typo

if ("Medium".equals(props.getProperty("Strength"))) {
}
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17102595
try like this:
"Thursday".equals(props.getProperty("Day"));
0
 

Author Comment

by:atwork2003
ID: 17102862
Works. Great...Thanks:-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17103218
:-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question