Java, Removing backslash in string object

前端 未结 4 784
梦谈多话
梦谈多话 2020-12-10 21:20

I have a URL like this: http:\\/\\/www.example.com\\/example in a string object.

Can somebody tell me, how to remove the backslashes? <

4条回答
  •  悲哀的现实
    2020-12-10 21:53

    Only this works for me -

    String url = "http:\/\/imgd2.aeplcdn.com\/310x174\/cw\/cars\/ford\/ford-figo-aspire.jpg";
    
        for(int i = 0; i < url.length(); i++)
            if(url.charAt(i) == '\\')
                url = url.substring(0, i) + url.substring(i + 1, url.length());
    

提交回复
热议问题