• Post Reply Bookmark Topic Watch Topic
  • New Topic

replace special characters from string in the java

 
Ranjan Prasad Mehta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i had a relative path ie
D:/Working/geotrak/web/reports/SpeedReport.jasper";

in this relative path i want to replase the Backslash(/) by Forwordslash(\)

Can any one say me how to do this in java

Example:

String str="/Working/geotrak/web/reports/SpeedReport.jasper";

String newStr = str.replace ('//' , '\\' );

System.out.println("old = " + str);
System.out.println("new = " + newStr);

But it not Replashing this / from \; no change happen so Help me to correct it


Thank inn Advance
 
Eduardo Bueno
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've messed up the names.

Your code doesn't even compile; forwardslash is a normal character, you just need to use one ('/').
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!