Hi, Pls help me with this issue. Contents of the text file: bla bla bla %s bla bla bla bla
...more contents here... %i bla bla %s --end of text file.
I would like to replace the %s,%i,%s with 3 values i pass in the arguments. eg. if send 1,2,3 then contents of the text file should have %s replaced with 1, %i replaced with 2 and %s replaced with 3. (in the order they appear in the file). I dont need to bother with whether its %s or %i, but only i need to replace %s or %i with the parameters i pass. I can read the contents of the file into a string. but how to replace values in the order specified.
Joined: Feb 28, 2006
Perhaps you could use a Collection class with key/value pairs where %s is a key and 1 is its value, or possibly vice-versa. I could be misinterpreting your dilemma however!
Joined: Jan 17, 2006
You could call the String.replaceFirst() method three different times with the same regex and different repacement Strings
[ April 20, 2006: Message edited by: Garrett Rowe ]
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names, with a first and a last name -- like Chitra Jay, for example.