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

Print this page
rev 10519 : 8054720: Modifications of I/O methods for instrumentation purposes
Summary: Wrap some native methods in Java methods.
Reviewed-by: TBD


 239     public FileOutputStream(FileDescriptor fdObj) {
 240         SecurityManager security = System.getSecurityManager();
 241         if (fdObj == null) {
 242             throw new NullPointerException();
 243         }
 244         if (security != null) {
 245             security.checkWrite(fdObj);
 246         }
 247         this.fd = fdObj;
 248         this.append = false;
 249         this.path = null;
 250 
 251         fd.attach(this);
 252     }
 253 
 254     /**
 255      * Opens a file, with the specified name, for overwriting or appending.
 256      * @param name name of file to be opened
 257      * @param append whether the file is to be opened in append mode
 258      */
 259     private native void open(String name, boolean append)
 260         throws FileNotFoundException;
 261 











 262     /**
 263      * Writes the specified byte to this file output stream.
 264      *
 265      * @param   b   the byte to be written.
 266      * @param   append   {@code true} if the write operation first
 267      *     advances the position to the end of file
 268      */
 269     private native void write(int b, boolean append) throws IOException;
 270 
 271     /**
 272      * Writes the specified byte to this file output stream. Implements
 273      * the <code>write</code> method of <code>OutputStream</code>.
 274      *
 275      * @param      b   the byte to be written.
 276      * @exception  IOException  if an I/O error occurs.
 277      */
 278     public void write(int b) throws IOException {
 279         write(b, append);
 280     }
 281 




 239     public FileOutputStream(FileDescriptor fdObj) {
 240         SecurityManager security = System.getSecurityManager();
 241         if (fdObj == null) {
 242             throw new NullPointerException();
 243         }
 244         if (security != null) {
 245             security.checkWrite(fdObj);
 246         }
 247         this.fd = fdObj;
 248         this.append = false;
 249         this.path = null;
 250 
 251         fd.attach(this);
 252     }
 253 
 254     /**
 255      * Opens a file, with the specified name, for overwriting or appending.
 256      * @param name name of file to be opened
 257      * @param append whether the file is to be opened in append mode
 258      */
 259     private native void open0(String name, boolean append)
 260         throws FileNotFoundException;
 261 
 262     // wrap native call to allow instrumentation
 263     /**
 264      * Opens a file, with the specified name, for overwriting or appending.
 265      * @param name name of file to be opened
 266      * @param append whether the file is to be opened in append mode
 267      */
 268     private void open(String name, boolean append)
 269         throws FileNotFoundException {
 270         open0(name, append);
 271     }
 272 
 273     /**
 274      * Writes the specified byte to this file output stream.
 275      *
 276      * @param   b   the byte to be written.
 277      * @param   append   {@code true} if the write operation first
 278      *     advances the position to the end of file
 279      */
 280     private native void write(int b, boolean append) throws IOException;
 281 
 282     /**
 283      * Writes the specified byte to this file output stream. Implements
 284      * the <code>write</code> method of <code>OutputStream</code>.
 285      *
 286      * @param      b   the byte to be written.
 287      * @exception  IOException  if an I/O error occurs.
 288      */
 289     public void write(int b) throws IOException {
 290         write(b, append);
 291     }
 292