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

Posted by Mannaz on Stack Overflow See other posts from Stack Overflow or by Mannaz
Published on 2010-04-07T14:21:28Z Indexed on 2010/04/07 14:33 UTC
Read the original article Hit count: 470

Filed under:
|
|
|
|

I have a string representing an URL containing spaces and want to convert it to an URI object. If is simple try to do

String myString = "http://myhost.com/media/mp3s/9/Agenda of swine - 13. Persecution Ascension_ leave nothing standing.mp3";
URI myUri = new URI(myString);

it gives me

java.net.URISyntaxException: Illegal character in path at index X

where index X is the position of the first space in the URL string.

How can i parse myStringinto a URI object?

© Stack Overflow or respective owner

Related posts about android

Related posts about java