[英]Android, how to replace slashes in path
i have an image path : "UploadFile\\\\/UserProfile\\\\/Female.jpg"
. 我有一个图像路径:
"UploadFile\\\\/UserProfile\\\\/Female.jpg"
。 How to replace "\\\\/"
with "/"
? 如何用
"\\\\/"
替换"\\\\/"
"/"
? i have tried : 我努力了 :
replaceAll("\\\\/","/")
replaceAll("\\\\\\\\/","/")
Code: 码:
adapter_profilepic = objUser.getProfilePicture().replaceAll("\\/","/");
This works : 这有效 :
String src = "UploadFile\\/UserProfile\\/Female.jpg";
src = src.replaceAll("\\\\/","/");
System.out.println(src);
output: 输出:
UploadFile/UserProfile/Female.jpg
You said you tried it, but check it again. 您说您尝试过,但是要再次检查。
According documentation your string is used as regular expression
. 根据文档,您的字符串用作
regular expression
。 Why you don't using replace : 为什么不使用replace :
String adapter_profilepic = objUser.getProfilePicture().replace("\\\\/","/");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.