Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
    
    AutoCloseOutputStream
    open class AutoCloseOutputStream : ParcelFileDescriptor.AutoCloseOutputStream
    
    An OutputStream you can create on a ParcelFileDescriptor, which will take care of calling android.os.ParcelFileDescriptor#close for you when the stream is closed.
    Summary
    
    
    
      
        
          | Inherited functions | 
        
          |  | 
        
          | From class FileOutputStream
                
                  
                    | Unit | finalize()
                         Cleans up the connection to the file, and ensures that the closemethod of this file output stream is called when there are no more references to this stream. |  
                    | FileChannel! | getChannel()
                         Returns the unique FileChannelobject associated with this file output stream.  The initial  positionof the returned channel will be equal to the number of bytes written to the file so far unless this stream is in append mode, in which case it will be equal to the size of the file. Writing bytes to this stream will increment the channel's position accordingly. Changing the channel's position, either explicitly or by writing, will change this stream's file position. |  
                    | FileDescriptor! | getFD()
                         Returns the file descriptor associated with this stream. |  
                    | Unit | write(b: ByteArray!)
                         Writes b.lengthbytes from the specified byte array to this file output stream. |  
                    | Unit | write(b: ByteArray!, off: Int, len: Int)
                         Writes lenbytes from the specified byte array starting at offsetoffto this file output stream. |  
                    | Unit | write(b: Int)
                         Writes the specified byte to this file output stream. Implements the writemethod ofOutputStream. |  | 
        
          | From class OutputStream
                
                  
                    | Unit | flush()
                         Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flushis that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.  If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.   The flushmethod ofOutputStreamdoes nothing. |  
                    | OutputStream! | nullOutputStream()
                         Returns a new OutputStreamwhich discards all bytes. The returned stream is initially open. The stream is closed by calling theclose()method. Subsequent calls toclose()have no effect.  While the stream is open, the write(int),write(byte[]), andwrite(byte[], int, int)methods do nothing. After the stream has been closed, these methods all throwIOException.  The flush()method does nothing. |  | 
      
    
    Public constructors
    
    Public methods
    
      write
      
      open fun write(buffer: ByteArray!): Unit
      
      
        
          
            | Exceptions | 
          
            | java.io.IOException | if an I/O error occurs. | 
        
      
     
    
      write
      
      open fun write(
    buffer: ByteArray!, 
    offset: Int, 
    count: Int
): Unit
      
        
          
            | Parameters | 
          
            | b | the data. | 
          
            | off | the start offset in the data. | 
          
            | len | the number of bytes to write. | 
        
      
      
        
          
            | Exceptions | 
          
            | java.io.IOException | if an I/O error occurs. | 
        
      
     
    
      write
      
      open fun write(oneByte: Int): Unit
      
        
          
            | Parameters | 
          
            | b | the byte to be written. | 
        
      
      
        
          
            | Exceptions | 
          
            | java.io.IOException | if an I/O error occurs. | 
        
      
     
  
  
  
    
  
 
  
    
    
      
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2025-02-10 UTC.
  
  
  
    
      [null,null,["Last updated 2025-02-10 UTC."],[],[]]