8068498: Remove constructor dependency on line.separator from PrintWriter and BufferedWriter

Reviewed-by: alanb, sherman
This commit is contained in:
Claes Redestad 2015-01-06 06:49:52 +01:00
parent f080b654f5
commit 3a90ffa2ab
2 changed files with 4 additions and 21 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -72,12 +72,6 @@ public class BufferedWriter extends Writer {
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.
@ -105,9 +99,6 @@ public class BufferedWriter extends Writer {
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 */
@ -240,7 +231,7 @@ public class BufferedWriter extends Writer {
* @exception IOException If an I/O error occurs
*/
public void newLine() throws IOException {
write(lineSeparator);
write(System.lineSeparator());
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -68,12 +68,6 @@ public class PrintWriter extends Writer {
private Formatter formatter;
private PrintStream psOut = null;
/**
* Line separator string. This is the value of the line.separator
* property at the moment that the stream was created.
*/
private final String lineSeparator;
/**
* Returns a charset object for the given charset name.
* @throws NullPointerException is csn is null
@ -113,8 +107,6 @@ public class PrintWriter extends Writer {
super(out);
this.out = out;
this.autoFlush = autoFlush;
lineSeparator = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("line.separator"));
}
/**
@ -477,7 +469,7 @@ public class PrintWriter extends Writer {
try {
synchronized (lock) {
ensureOpen();
out.write(lineSeparator);
out.write(System.lineSeparator());
if (autoFlush)
out.flush();
}