View Single Post
  #2 (permalink)  
Old 08-02-2007, 11:11 PM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Backslashes in java are escape tokens. To use them as character literals they need to be preceded by a backslash, ie, escaped. So if you want '\' to appear you have to write it as '\\'.
Code:
String escapedLetters = "C:\file\test.txt"; System.out.println("escapedLetters = " + escapedLetters); String url = "C:\\file\\test.txt"; System.out.println("url = " + url); String converted = url.replace('\\','/'); System.out.println("converted = " + converted);
Reply With Quote