-3

In my android program I want to replace all backslash(\) with slash(/) in a string. Replace All did not work for that.So please help me.

ngrashia
  • 9,869
  • 5
  • 43
  • 58

3 Answers3

1

Try text.replace('\\', '/') where text is a String.

Gili
  • 86,244
  • 97
  • 390
  • 689
0

Try below Code:

String origString = "file\\folder\\a.png";
String newString = origString.replaceAll("\\\\","/");
System.out.println (newString);

Output:

file/folder/a.png
ngrashia
  • 9,869
  • 5
  • 43
  • 58
0

Try this:

String test = ...
test.replace("\\", "/");
kodartcha
  • 1,063
  • 12
  • 23