public static class

AssetFileDescriptor.AutoCloseInputStream

extends ParcelFileDescriptor.AutoCloseInputStream
java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.FileInputStream
       ↳ android.os.ParcelFileDescriptor.AutoCloseInputStream
         ↳ android.content.res.AssetFileDescriptor.AutoCloseInputStream

Class Overview

An InputStream you can create on a ParcelFileDescriptor, which will take care of calling ParcelFileDescritor.close() for you when the stream is closed.

Summary

Public Constructors
AssetFileDescriptor.AutoCloseInputStream(AssetFileDescriptor fd)
Public Methods
int available()
Returns the number of bytes that are available before this stream will block.
void mark(int readlimit)
Sets a mark position in this InputStream.
boolean markSupported()
Indicates whether this stream supports the mark() and reset() methods.
int read(byte[] buffer, int offset, int count)
Reads at most count bytes from this stream and stores them in the byte array buffer starting at offset.
int read(byte[] buffer)
Reads bytes from this stream and stores them in the byte array buffer.
int read()
Reads a single byte from this stream and returns it as an integer in the range from 0 to 255.
synchronized void reset()
Resets this stream to the last marked location.
long skip(long count)
Skips count number of bytes in this stream.
[Expand]
Inherited Methods
From class android.os.ParcelFileDescriptor.AutoCloseInputStream
From class java.io.FileInputStream
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable

Public Constructors

public AssetFileDescriptor.AutoCloseInputStream (AssetFileDescriptor fd)

Throws
IOException

Public Methods

public int available ()

Returns the number of bytes that are available before this stream will block. This method always returns the size of the file minus the current position.

Returns
  • the number of bytes available before blocking.
Throws
IOException

public void mark (int readlimit)

Sets a mark position in this InputStream. The parameter readlimit indicates how many bytes can be read before the mark is invalidated. Sending reset() will reposition the stream back to the marked position provided readLimit has not been surpassed.

This default implementation does nothing and concrete subclasses must provide their own implementation.

Parameters
readlimit the number of bytes that can be read from this stream before the mark is invalidated.

public boolean markSupported ()

Indicates whether this stream supports the mark() and reset() methods. The default implementation returns false.

Returns
  • always false.

public int read (byte[] buffer, int offset, int count)

Reads at most count bytes from this stream and stores them in the byte array buffer starting at offset.

Parameters
buffer the byte array in which to store the bytes read.
offset the initial position in buffer to store the bytes read from this stream.
count the maximum number of bytes to store in buffer.
Returns
  • the number of bytes actually read or -1 if the end of the stream has been reached.
Throws
IOException

public int read (byte[] buffer)

Reads bytes from this stream and stores them in the byte array buffer.

Parameters
buffer the byte array in which to store the bytes read.
Returns
  • the number of bytes actually read or -1 if the end of the stream has been reached.
Throws
IOException

public int read ()

Reads a single byte from this stream and returns it as an integer in the range from 0 to 255. Returns -1 if the end of this stream has been reached.

Returns
  • the byte read or -1 if the end of this stream has been reached.
Throws
IOException

public synchronized void reset ()

Resets this stream to the last marked location. Throws an IOException if the number of bytes read since the mark has been set is greater than the limit provided to mark, or if no mark has been set.

This implementation always throws an IOException and concrete subclasses should provide the proper implementation.

Throws
IOException

public long skip (long count)

Skips count number of bytes in this stream. Subsequent read()'s will not return these bytes unless reset() is used. This method may perform multiple reads to read count bytes.

Parameters
count the number of bytes to skip.
Returns
  • the number of bytes actually skipped.
Throws
IOException