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
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.
finalPartOfString