Hi Michael,
Created:
8219992 <https://bugs.openjdk.java.net/browse/JDK-8219992> Correct the
documentation of PrintWriter to refer System.lineSeparator
Given the caching of the system property value is unspecified, the
current text is
not completely wrong. The value used is taken from line.separator but
its initial value,
not dynamically.
Thanks, Roger
On 3/1/19 12:43 PM, Michael Rasmussen wrote:
Hi,
When JDK-8068498 was implemented (in JDK9), it simply changed PrintWriter and
BufferedWriter to use System.lineSeparator(), but the spec for the classes and
methods still mentions line.separator system property, thus giving the
impression that changing that system property has an impact.
I know that JDK-8068498 was there to counter people from doing stuff like:
System.setProperty("line.separator", "\n");
unixBW = new BufferedWriter(...)
But according to the javadoc for BufferedWriter, the value of that property
should impact how the writer works.
This also applies to a method like Files.write(path, lines), where .newLine()
is implicitly called after each element in the lines Iterable, and again the
line.separator system property is explicitly mentioned in the spec for that
method.
The spec for these classes and methods should probably be updated to reference
System.lineSeparator() instead?
/Michael