aspose file tools*
The moose likes Servlets and the fly likes Please help me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Please help me" Watch "Please help me" New topic
Author

Please help me

Garry Kalra
Ranch Hand

Joined: May 25, 2001
Posts: 111
Please tell me how to do this. I've got a String named schoolName as
String schoolName = "[School][Category][Type]";
I want to convert all those [ in the string to [= and all
tose ] to +]. Please tell me if there is a function to do so. I
understand that i can do so by scanning through the String, but i
need a function that replaces a single character with a string.
Hope i have made myself clear, if not still, please tell me.
Gaurav Kalra
k b
Greenhorn

Joined: Feb 01, 2001
Posts: 22
// Here is a method that can help your problem

private String replaceText(String orig, char c, String s){
String modified =orig;
while(orig.indexOf(c) != -1){
int index = orig.indexOf(c);
modified = orig.substring(0,index) + s + orig.substring(index+1);
orig = modified;
}
return modified;
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help me