310 /** 311 * Writes the specified byte to this file output stream. Implements 312 * the <code>write</code> method of <code>OutputStream</code>. 313 * 314 * @param b the byte to be written. 315 * @exception IOException if an I/O error occurs. 316 */ 317 public void write(int b) throws IOException { 318 write(b, fdAccess.getAppend(fd)); 319 } 320 321 /** 322 * Writes a sub array as a sequence of bytes. 323 * @param b the data to be written 324 * @param off the start offset in the data 325 * @param len the number of bytes that are written 326 * @param append {@code true} to first advance the position to the 327 * end of file 328 * @exception IOException If an I/O error has occurred. 329 */ 330 private native void writeBytes(byte b[], int off, int len, boolean append) 331 throws IOException; 332 333 /** 334 * Writes <code>b.length</code> bytes from the specified byte array 335 * to this file output stream. 336 * 337 * @param b the data. 338 * @exception IOException if an I/O error occurs. 339 */ 340 public void write(byte b[]) throws IOException { 341 writeBytes(b, 0, b.length, fdAccess.getAppend(fd)); 342 } 343 344 /** 345 * Writes <code>len</code> bytes from the specified byte array 346 * starting at offset <code>off</code> to this file output stream. 347 * 348 * @param b the data. 349 * @param off the start offset in the data. 350 * @param len the number of bytes to write. 351 * @exception IOException if an I/O error occurs. 352 */ 353 public void write(byte b[], int off, int len) throws IOException { 354 writeBytes(b, off, len, fdAccess.getAppend(fd)); 355 } 356 357 /** 358 * Closes this file output stream and releases any system resources 359 * associated with this stream. This file output stream may no longer 360 * be used for writing bytes. 361 * 362 * <p> If this stream has an associated channel then the channel is closed 363 * as well. 364 * 365 * @apiNote 366 * Overriding {@link #close} to perform cleanup actions is reliable 367 * only when called directly or when called by try-with-resources. 368 * Do not depend on finalization to invoke {@code close}; 369 * finalization is not reliable and is deprecated. 370 * If cleanup of native resources is needed, other mechanisms such as 371 * {@linkplain java.lang.ref.Cleaner} should be used. 372 * 373 * @exception IOException if an I/O error occurs. | 310 /** 311 * Writes the specified byte to this file output stream. Implements 312 * the <code>write</code> method of <code>OutputStream</code>. 313 * 314 * @param b the byte to be written. 315 * @exception IOException if an I/O error occurs. 316 */ 317 public void write(int b) throws IOException { 318 write(b, fdAccess.getAppend(fd)); 319 } 320 321 /** 322 * Writes a sub array as a sequence of bytes. 323 * @param b the data to be written 324 * @param off the start offset in the data 325 * @param len the number of bytes that are written 326 * @param append {@code true} to first advance the position to the 327 * end of file 328 * @exception IOException If an I/O error has occurred. 329 */ 330 private native void writeBytes(byte[] b, int off, int len, boolean append) 331 throws IOException; 332 333 /** 334 * Writes <code>b.length</code> bytes from the specified byte array 335 * to this file output stream. 336 * 337 * @param b the data. 338 * @exception IOException if an I/O error occurs. 339 */ 340 public void write(byte[] b) throws IOException { 341 writeBytes(b, 0, b.length, fdAccess.getAppend(fd)); 342 } 343 344 /** 345 * Writes <code>len</code> bytes from the specified byte array 346 * starting at offset <code>off</code> to this file output stream. 347 * 348 * @param b the data. 349 * @param off the start offset in the data. 350 * @param len the number of bytes to write. 351 * @exception IOException if an I/O error occurs. 352 */ 353 public void write(byte[] b, int off, int len) throws IOException { 354 writeBytes(b, off, len, fdAccess.getAppend(fd)); 355 } 356 357 /** 358 * Closes this file output stream and releases any system resources 359 * associated with this stream. This file output stream may no longer 360 * be used for writing bytes. 361 * 362 * <p> If this stream has an associated channel then the channel is closed 363 * as well. 364 * 365 * @apiNote 366 * Overriding {@link #close} to perform cleanup actions is reliable 367 * only when called directly or when called by try-with-resources. 368 * Do not depend on finalization to invoke {@code close}; 369 * finalization is not reliable and is deprecated. 370 * If cleanup of native resources is needed, other mechanisms such as 371 * {@linkplain java.lang.ref.Cleaner} should be used. 372 * 373 * @exception IOException if an I/O error occurs. |