aspose file tools*
The moose likes Beginning Java and the fly likes String.replace to remove a character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String.replace to remove a character" Watch "String.replace to remove a character" New topic
Author

String.replace to remove a character

Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
I know you can use String.replace to replace a character with a space but can you use this same method to remove the character?
I.E
-----------
String st = "I'm";
st = st.replace('\'','some character I dont know about');
System.out.println(st);
-------------
would print Im
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
sorry but i don't know if a empty char exist!
if you have to do this use a little loop like this:

------------------
Benjamin l´┐Żonard
www.evisor.com
Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
Cool. THANKS.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: String.replace to remove a character
 
Similar Threads
string.replace limited to only one character.
replacing space in file
Using contains/equals/== with random characters?
How to remove '\0'
character representation of a blank space