Search code examples
javaurlencodeurl-encoding

How to URLEncode a partial encoded text in Java?


If the following string is what I want to url-encode,

@test123: http://news.yahoo.com/fifa%E6%96%A5%E8%B3%87%E5%8D%83%E8%90%AC-%E5%8A%A9%E6%88%91%E8%B6%B3%E7%90%83%E5%8D%87%E7%B4%9A-185314701.html check out the news.

I tried to url-encode the full string but it still url-encode the following url-encoded part of the string.

http://news.yahoo.com/fifa%E6%96%A5%E8%B3%87%E5%8D%83%E8%90%AC-%E5%8A%A9%E6%88%91%E8%B6%B3%E7%90%83%E5%8D%87%E7%B4%9A-185314701.html

And it caused the server failed to identify the request.

How should I accomplish this?


Solution

  • Decode it all, and then encode it.

    Also, if it is already encoded, why are you trying to encode it again?