This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Passing Externally values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Passing Externally values" Watch "Passing Externally values" New topic
Author

Passing Externally values

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
I have some values ...which i wish to pass externally from a file to the program.

But there are repetitive param names for certain values..

Suppose,

Field1=value1
Field1=value2
Field1=value3

What is the best strategy if i want to handle these kind of values..??

I tried using properties but it wont allow duplicate keys..

Regards
Nupur Gupta
Ranch Hand

Joined: Aug 02, 2006
Posts: 45
Try creating an object with all the params!
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Try creating an object with all the params


What type of an object are you referring to ???
Nupur Gupta
Ranch Hand

Joined: Aug 02, 2006
Posts: 45
Any object that encapsulates all the features. If you want to know more about objects, read any basic book on java.
Srikanth Ramu
Ranch Hand

Joined: Feb 20, 2007
Posts: 76
If the values are in a file in the above given format, then you need to parse the file using StringTokenizer.

You could either store them in Key-Values structure or have your own object structure like setKey(key), setValues(valueList).
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Property files are out because of duplicate keys, but you can make files that look the same and parse them yourself. Srikanth's tip about StringTokenizer was a good start.

See if this multimap example gives you some ideas about storing multiple values for one key.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Thanks Srikanth and Stan... i will try to proceed with this...
[ April 06, 2007: Message edited by: A Kumar ]
 
Consider Paul's rocket mass heater.
 
subject: Passing Externally values
 
Similar Threads
Float to String
Query Question
Passing args0 in validation.xml dynamically
why doesnt hibernate log input ?
Hibernate: Running a query using an object