Android: how to parse URL String with spaces to URI object?

前端 未结 5 1487
孤城傲影
孤城傲影 2020-11-27 03:52

I have a string representing an URL containing spaces and want to convert it to an URI object. If I simply try to create it via

String myString = \"http://my         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 03:58

    java.net.URLEncoder.encode(finalPartOfString, "utf-8");
    

    This will URL-encode the string.

    finalPartOfString is the part after the last slash - in your case, the name of the song, as it seems.

提交回复
热议问题