-
Enhancement
-
Resolution: Fixed
-
P3
-
None
-
b36
For example, these APIs take a charset name:
ByteArrayOutputStream.toString(csname)
PrintStream(File, csname)
PrintStream(filename, csname)
PrintWriter(File, csname)
PrintWriter(filename, csname)
and are declared to throw UnsupportedEncodingException, which is checked, making them inconvenient to use. (Although UEE is a subtype of IOException, and calls to these often, but not always, occur in contexts where IOException is caught or declared.) Other APIs throw IllegalArgumentException if the charset name is invalid:
Scanner(File, csname)
... other Scanner constructor overloads ...
This is less inconvenient, however, for programmability, one always has to look up or remember the right name. (Is it "UTF_8" to be consistent with StandardCharsets.UTF_8? No, it's "UTF-8".)
Still other APIs don't have any charset-related parameters at all:
FileReader(File)
FileReader(FileDescriptor)
FileReader(filename)
FileWriter(File)
FileWriter(File, append)
FileWriter(FileDescriptor)
FileWriter(filename)
FileWriter(filename, append)
In all these cases an overload taking a Charset parameter should be added.
This isn't an exhaustive list. The APIs should be audited for additional occurrences of APIs that have similar issues.
- csr for
-
JDK-8190577 Add Constructors/Methods that take a Charset parameter to APIs in java.io, java.net, java.nio and java.util
-
- Closed
-
- duplicates
-
JDK-8130725 ByteArrayOutputStream should have a toString(Charset) method
-
- Closed
-
-
JDK-8134807 (scanner) Scanner should have constructor overloads that take Charset
-
- Closed
-
-
JDK-8167648 java.io.PrintWriter should have PrintWriter((String|File), Charset) constructors
-
- Closed
-
- relates to
-
JDK-8183554 Add constructors with Charset parameter for FileReader and FileWriter
-
- Resolved
-
-
JDK-8130725 ByteArrayOutputStream should have a toString(Charset) method
-
- Closed
-
-
JDK-8134807 (scanner) Scanner should have constructor overloads that take Charset
-
- Closed
-
-
JDK-8167648 java.io.PrintWriter should have PrintWriter((String|File), Charset) constructors
-
- Closed
-
-
JDK-8178704 Add Charset overloads to URLDecoder and URLEncoder
-
- Closed
-