java 如何替换String 所有指定字符,求助

String filerootori=chooser.getSelectedFile()+"";
String[] filerootArray=filerootori.split("'\u005C'");
for(int i=1;i<filerootArray.length;i++)
{
fileroot+=filerootArray[i]+"/";
}
System.out.println(fileroot);

我想把读取的文件路径中的“\”全部改成“/”,这样怎么不行?
输出是空白。

然后用replaceAll(regax,String)也没用……,根本没变……

不需要那么拆装
直接text=text.replace("\\","/");
就全部替换了。
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-12-21
String a = "c:\\dic\\text.txt";
String b = a.replaceAll("\\\\", "/");
System.out.println(b);

----------------
c:/dic/text.txt
第2个回答  2011-12-21
System.out.println("e:\\wsfds\\sdfds".replace("\\", "/")); 可以执行
相似回答