JDK-8167648: java.io.PrintWriter should have PrintWriter((String|File), Charset) constructors

Patrick Reinhart patrick at reini.net
Fri Nov 18 09:19:35 UTC 2016


I was looking at the existing JDK 9 issues for some simple ones I could 
solve and found this one. I wanted to know if it makes sense to add 
additional constructors here?

Now you need to do this:
------------------------
try {
   new PrintWriter(file, "UTF-8");
} catch (UnsupportedEncodingException e) {
   // Ignore, this is required to be supported by the JVM.
}

The same applies also to the String constructor...



Instead the following behaviour is requested:
---------------------------------------------
new PrintWriter(file, StandardCharsets.UTF_8));



On the other hand then the next request will be to add constructors also 
to specify autoflush and so on...

-Patrick


More information about the core-libs-dev mailing list