src/share/classes/java/io/FileOutputStream.java
Print this page
rev 9260 : imported patch io-events-path
@@ -65,10 +65,15 @@
/**
* The associated channel, initialized lazily.
*/
private FileChannel channel;
+ /**
+ * The path of the referenced file (null if the stream is created with a file descriptor)
+ */
+ private final String path;
+
private final Object closeLock = new Object();
private volatile boolean closed = false;
/**
* Creates a file output stream to write to the file with the
@@ -200,10 +205,11 @@
throw new FileNotFoundException("Invalid file path");
}
this.fd = new FileDescriptor();
fd.attach(this);
this.append = append;
+ this.path = name;
open(name, append);
}
/**
@@ -237,10 +243,11 @@
if (security != null) {
security.checkWrite(fdObj);
}
this.fd = fdObj;
this.append = false;
+ this.path = null;
fd.attach(this);
}
/**
@@ -374,11 +381,11 @@
* @spec JSR-51
*/
public FileChannel getChannel() {
synchronized (this) {
if (channel == null) {
- channel = FileChannelImpl.open(fd, false, true, append, this);
+ channel = FileChannelImpl.open(fd, path, false, true, append, this);
}
return channel;
}
}