< prev index next >

src/java.base/share/classes/java/io/BufferedWriter.java

Print this page
rev 11212 : 8068498: Remove constructor dependency on line.separator from PrintWriter and BufferedWriter

@@ -71,16 +71,10 @@
     private int nChars, nextChar;
 
     private static int defaultCharBufferSize = 8192;
 
     /**
-     * Line separator string.  This is the value of the line.separator
-     * property at the moment that the stream was created.
-     */
-    private String lineSeparator;
-
-    /**
      * Creates a buffered character-output stream that uses a default-sized
      * output buffer.
      *
      * @param  out  A Writer
      */

@@ -103,13 +97,10 @@
             throw new IllegalArgumentException("Buffer size <= 0");
         this.out = out;
         cb = new char[sz];
         nChars = sz;
         nextChar = 0;
-
-        lineSeparator = java.security.AccessController.doPrivileged(
-            new sun.security.action.GetPropertyAction("line.separator"));
     }
 
     /** Checks to make sure that the stream has not been closed */
     private void ensureOpen() throws IOException {
         if (out == null)

@@ -238,11 +229,11 @@
      * newline ('\n') character.
      *
      * @exception  IOException  If an I/O error occurs
      */
     public void newLine() throws IOException {
-        write(lineSeparator);
+        write(System.lineSeparator());
     }
 
     /**
      * Flushes the stream.
      *
< prev index next >