提交 420617ce 编写于 作者: M martin

6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code

Reviewed-by: alanb, iris
上级 c3da802e
......@@ -48,15 +48,15 @@ public
class FileInputStream extends InputStream
{
/* File Descriptor - handle to the open file */
private FileDescriptor fd;
private final FileDescriptor fd;
private FileChannel channel = null;
private Object closeLock = new Object();
private final Object closeLock = new Object();
private volatile boolean closed = false;
private static ThreadLocal<Boolean> runningFinalize =
new ThreadLocal<Boolean>();
private static final ThreadLocal<Boolean> runningFinalize =
new ThreadLocal<Boolean>();
private static boolean isRunningFinalize() {
Boolean val;
......@@ -151,7 +151,7 @@ class FileInputStream extends InputStream
* is thrown.
* <p>
* This constructor does not throw an exception if <code>fdObj</code>
* is {link java.io.FileDescriptor#valid() invalid}.
* is {@link java.io.FileDescriptor#valid() invalid}.
* However, if the methods are invoked on the resulting stream to attempt
* I/O on the stream, an <code>IOException</code> is thrown.
*
......@@ -389,7 +389,7 @@ class FileInputStream extends InputStream
* @see java.io.FileInputStream#close()
*/
protected void finalize() throws IOException {
if ((fd != null) && (fd != fd.in)) {
if ((fd != null) && (fd != FileDescriptor.in)) {
/*
* Finalizer should not release the FileDescriptor if another
......
......@@ -52,20 +52,18 @@ public
class FileOutputStream extends OutputStream
{
/**
* The system dependent file descriptor. The value is
* 1 more than actual file descriptor. This means that
* the default value 0 indicates that the file is not open.
* The system dependent file descriptor.
*/
private FileDescriptor fd;
private final FileDescriptor fd;
private FileChannel channel= null;
private boolean append = false;
private Object closeLock = new Object();
private final Object closeLock = new Object();
private volatile boolean closed = false;
private static ThreadLocal<Boolean> runningFinalize =
new ThreadLocal<Boolean>();
private static final ThreadLocal<Boolean> runningFinalize =
new ThreadLocal<Boolean>();
private static boolean isRunningFinalize() {
Boolean val;
......@@ -75,7 +73,7 @@ class FileOutputStream extends OutputStream
}
/**
* Creates an output file stream to write to the file with the
* Creates a file output stream to write to the file with the
* specified name. A new <code>FileDescriptor</code> object is
* created to represent this file connection.
* <p>
......@@ -100,8 +98,8 @@ class FileOutputStream extends OutputStream
}
/**
* Creates an output file stream to write to the file with the specified
* <code>name</code>. If the second argument is <code>true</code>, then
* Creates a file output stream to write to the file with the specified
* name. If the second argument is <code>true</code>, then
* bytes will be written to the end of the file rather than the beginning.
* A new <code>FileDescriptor</code> object is created to represent this
* file connection.
......@@ -211,7 +209,7 @@ class FileOutputStream extends OutputStream
}
/**
* Creates an output file stream to write to the specified file
* Creates a file output stream to write to the specified file
* descriptor, which represents an existing connection to an actual
* file in the file system.
* <p>
......@@ -223,7 +221,7 @@ class FileOutputStream extends OutputStream
* is thrown.
* <p>
* This constructor does not throw an exception if <code>fdObj</code>
* is {link java.io.FileDescriptor#valid() invalid}.
* is {@link java.io.FileDescriptor#valid() invalid}.
* However, if the methods are invoked on the resulting stream to attempt
* I/O on the stream, an <code>IOException</code> is thrown.
*
......@@ -408,7 +406,7 @@ class FileOutputStream extends OutputStream
*/
protected void finalize() throws IOException {
if (fd != null) {
if (fd == fd.out || fd == fd.err) {
if (fd == FileDescriptor.out || fd == FileDescriptor.err) {
flush();
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册