0

I have a question regarding url encoding. Trying to encode the url and could not get it working. Tried java.net.URLEncode.

I have url http://msnbcmedia4.msn.com/i/MSNBC/Components/Photo/_new/130409_luke hancock.jpg and I need to encode it. From online forums my understanding is that I should only encode queryparams and url path excluding fqdn(http://msnbcmedia4.msn.com). Should I need to encode(/ in url path, ? and & in parameters) or skip encoding these. I am trying to download the content from this specific location using java. Any info would be appreciated.

akd
  • 1,427
  • 3
  • 16
  • 21

1 Answers1

0

URLEncoder is the right choice. You need to encode only individual Query string parameters name/value and not the entire URL. If you encode whole URL then it will encode Http and other URL parts as well which we don't want.

Check out this awesome answer >> https://stackoverflow.com/a/10786112/2093375

Regards,

Community
  • 1
  • 1
Ravi Trivedi
  • 2,340
  • 2
  • 14
  • 20