• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parsing var2={$var1.desc} like property  RSS feed

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

What is the easiest way to parse the following properties information:

## My properties file
var1=c:/temp
var2={$var1}/subdir/test
var3=something/{$var2}/etc


Is there any helper API to accomplish this or I still have to load the properties and pars them programmatically.

Thanks in advance.

JL
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends a good deal on what the purpose of the parsing is. If you want to extract the {...} sections and replace the variables, then that might be accomplished by using regular expressions.
[ August 25, 2005: Message edited by: Ulf Dittmer ]
 
Jose Ortuno
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK,

I am gonna review reg. exp. to eval & replace {$varname} by the value.

Thanks for writting..!!
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if Properties or PropertyResourceBundle do it for you.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a slight modification to your .properties file,

var1=c:/temp
var2={0}/subdir/test/{1}/test/{2}/data
var3=something/{0}/etc

======================



In fact, if you are doing web apps, you may want to consider using something like Struts because it has capabilities to grab the value with up to 4 parameters I think, ie: you can be lazy and use the built in API rather than write it yourself.
 
Jose Ortuno
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, a lot..!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!