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

Stephen Colebourne scolebourne at joda.org
Wed Nov 23 13:45:30 UTC 2016


Returning the writer was my intention. I also intended it to return a
new instance, to avoid changing the variable from final to non-final.
Stephen


On 23 November 2016 at 13:35, Jonathan Bluett-Duncan
<jbluettduncan at gmail.com> wrote:
> Hi Patrick,
>
> Have you considered making `withAutoFlush()` return the `PrintWriter`
> itself, allowing fluent code snippets like the following?
>
> ```
> PrintWriter writer = new PrintWriter(new File("path/to/file.txt"),
> StandardCharsets.UTF_8).withAutoFlush();
> ```
>
> Kind regards,
> Jonathan
>
> On 23 November 2016 at 13:09, Patrick Reinhart <patrick at reini.net> wrote:
>>
>> Added those new public constructors:
>>
>> PrintWriter(OutputStream, Charset)
>> PrintWriter(File, Charset)
>> withAutoFlush()
>>
>> Also added a new private constructor:
>>
>> PrintWriter(OutputStream, Charset, boolean)
>>
>> and rewired the OutputStream constructor calls to this private
>> constructor.
>>
>>
>> Here's the webrev:
>>
>> http://cr.openjdk.java.net/~reinhapa/reviews/8167648/webrev.00
>>
>>
>> -Patrick
>
>


More information about the core-libs-dev mailing list