JDK-8192381 : URLEncoder StandardCharset support
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8,9,10
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2017-11-29
  • Updated: 2022-07-04
  • Resolved: 2022-07-04
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
Right now if you want to URLEncode a string you need to pass a charset as a string which makes you have to catch an exception. 

JUSTIFICATION :
There is no reason to have to deal with an exception if the encode method can take a Charset. It can make the code design a bit nicer, so it's just a nice enhancement.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
URLEncoder.encode(String input, Charset charset) url encodes the input with the charset without throwing an exception.
ACTUAL -
We currently have to catch an exception


Comments
Added in JDK 10
04-07-2022

Seems to be a dup of JDK-8190577.
29-11-2017