我有一个字符串,它可以采用两种形式
第一种形式
file:///mnt/sdcard/myfolder/myfile.txt第二种形式
/file://mnt/sdcard/myfolder/myfile.txt并且我需要字符串始终以
/mnt/sdcard/myfolder/myfile.txt因此,我使用了replace命令
myPath=path.replace("file://", "");
myPath= path.replace("/file:/", "");但不幸的是它不能工作
和字符串myPath结果
file:///mnt/sdcard/myfolder/myfile.txt怎么啦?
发布于 2012-10-06 01:09:16
使用第二个调用覆盖第一个myPath = path.replace()调用,该调用可能不会替换任何内容,并返回整个字符串。
https://stackoverflow.com/questions/12750879
复制相似问题