-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.

Nishanthi Grashia
  • 9,787
  • 5
  • 42
  • 57

3 Answers3

1

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

Gili
  • 81,444
  • 90
  • 364
  • 657
0

Try below Code:

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

Output:

file/folder/a.png
Nishanthi Grashia
  • 9,787
  • 5
  • 42
  • 57
0

Try this:

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