src/share/classes/java/io/FileOutputStream.java

Print this page
rev 6052 : [mq]: jdk.patch

*** 25,34 **** --- 25,35 ---- package java.io; import java.nio.channels.FileChannel; import sun.nio.ch.FileChannelImpl; + import sun.misc.IoTrace; /** * A file output stream is an output stream for writing data to a * <code>File</code> or to a <code>FileDescriptor</code>. Whether or not
*** 56,65 **** --- 57,71 ---- * The system dependent file descriptor. */ private final FileDescriptor fd; /** + * The path of the referenced file (null if there is no file) + */ + private final String path; + + /** * True if the file is opened for append. */ private final boolean append; /**
*** 197,207 **** throw new NullPointerException(); } this.fd = new FileDescriptor(); fd.attach(this); this.append = append; ! open(name, append); } /** * Creates a file output stream to write to the specified file --- 203,213 ---- throw new NullPointerException(); } this.fd = new FileDescriptor(); fd.attach(this); this.append = append; ! this.path = name; open(name, append); } /** * Creates a file output stream to write to the specified file
*** 233,242 **** --- 239,249 ---- } if (security != null) { security.checkWrite(fdObj); } this.fd = fdObj; + this.path = null; this.append = false; fd.attach(this); }
*** 263,273 **** --- 270,282 ---- * * @param b the byte to be written. * @exception IOException if an I/O error occurs. */ public void write(int b) throws IOException { + Object traceHandle = IoTrace.fileWriteBegin(path); write(b, append); + IoTrace.fileWriteEnd(traceHandle, 1); } /** * Writes a sub array as a sequence of bytes. * @param b the data to be written
*** 286,296 **** --- 295,307 ---- * * @param b the data. * @exception IOException if an I/O error occurs. */ public void write(byte b[]) throws IOException { + Object traceHandle = IoTrace.fileWriteBegin(path); writeBytes(b, 0, b.length, append); + IoTrace.fileWriteEnd(traceHandle, b.length); } /** * Writes <code>len</code> bytes from the specified byte array * starting at offset <code>off</code> to this file output stream.
*** 299,309 **** --- 310,322 ---- * @param off the start offset in the data. * @param len the number of bytes to write. * @exception IOException if an I/O error occurs. */ public void write(byte b[], int off, int len) throws IOException { + Object traceHandle = IoTrace.fileWriteBegin(path); writeBytes(b, off, len, append); + IoTrace.fileWriteEnd(traceHandle, len); } /** * Closes this file output stream and releases any system resources * associated with this stream. This file output stream may no longer
*** 371,381 **** * @spec JSR-51 */ public FileChannel getChannel() { synchronized (this) { if (channel == null) { ! channel = FileChannelImpl.open(fd, false, true, append, this); } return channel; } } --- 384,394 ---- * @spec JSR-51 */ public FileChannel getChannel() { synchronized (this) { if (channel == null) { ! channel = FileChannelImpl.open(fd, path, false, true, append, this); } return channel; } }