File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Replacing characters Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Replacing characters " Watch "Replacing characters " New topic
Author

Replacing characters

Lila Fowler
Ranch Hand

Joined: Jul 31, 2009
Posts: 84
Hi all

Im automatically creating a folder with user information, but i have to make sure that there are no illegal characters and if there are i should replace it with a "0" but although it goes into my if statement it refuses to replace the invalid character.

here is the relevant code



Any idea's?
thanks.


Courage is not the absence of fear but rather the judgment that something is more important then fear. ~ Ambrose Redmond
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35247
    
    7
String.replace does not alter the string you're passing to it; rather, it returns the result of the replacement operation. You want something like " fileName = fileName.replace(... "


Android appsImageJ pluginsJava web charts
Lila Fowler
Ranch Hand

Joined: Jul 31, 2009
Posts: 84
oh duh.. Thanks, works perfectly now.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Replacing characters
 
Similar Threads
same stuff
StringBuffer/StringBuilder question - unexpected results
Eliminate unnecessary characters from a String
Capitalize first letter in string
Regex for replacing special characters