Constructors Summary |
---|
public AssetFileDescriptor(android.os.ParcelFileDescriptor fd, long startOffset, long length)Create a new AssetFileDescriptor from the given values.
this(fd, startOffset, length, null);
|
AssetFileDescriptor(android.os.Parcel src)
mFd = ParcelFileDescriptor.CREATOR.createFromParcel(src);
mStartOffset = src.readLong();
mLength = src.readLong();
if (src.readInt() != 0) {
mExtras = src.readBundle();
} else {
mExtras = null;
}
|
public AssetFileDescriptor(android.os.ParcelFileDescriptor fd, long startOffset, long length, android.os.Bundle extras)Create a new AssetFileDescriptor from the given values.
if (fd == null) {
throw new IllegalArgumentException("fd must not be null");
}
if (length < 0 && startOffset != 0) {
throw new IllegalArgumentException(
"startOffset must be 0 when using UNKNOWN_LENGTH");
}
mFd = fd;
mStartOffset = startOffset;
mLength = length;
mExtras = extras;
|
Methods Summary |
---|
public void | close()Convenience for calling getParcelFileDescriptor().close() .
mFd.close();
|
public java.io.FileInputStream | createInputStream()Create and return a new auto-close input stream for this asset. This
will either return a full asset {@link AutoCloseInputStream}, or
an underlying {@link ParcelFileDescriptor.AutoCloseInputStream
ParcelFileDescriptor.AutoCloseInputStream} depending on whether the
the object represents a complete file or sub-section of a file. You
should only call this once for a particular asset.
if (mLength < 0) {
return new ParcelFileDescriptor.AutoCloseInputStream(mFd);
}
return new AutoCloseInputStream(this);
|
public java.io.FileOutputStream | createOutputStream()Create and return a new auto-close output stream for this asset. This
will either return a full asset {@link AutoCloseOutputStream}, or
an underlying {@link ParcelFileDescriptor.AutoCloseOutputStream
ParcelFileDescriptor.AutoCloseOutputStream} depending on whether the
the object represents a complete file or sub-section of a file. You
should only call this once for a particular asset.
if (mLength < 0) {
return new ParcelFileDescriptor.AutoCloseOutputStream(mFd);
}
return new AutoCloseOutputStream(this);
|
public int | describeContents()
return mFd.describeContents();
|
public long | getDeclaredLength()Return the actual number of bytes that were declared when the
AssetFileDescriptor was constructed. Will be
{@link #UNKNOWN_LENGTH} if the length was not declared, meaning data
should be read to the end of the file.
return mLength;
|
public android.os.Bundle | getExtras()Returns any additional details that can be used to interpret the
underlying file descriptor. May be null.
return mExtras;
|
public java.io.FileDescriptor | getFileDescriptor()Returns the FileDescriptor that can be used to read the data in the
file.
return mFd.getFileDescriptor();
|
public long | getLength()Returns the total number of bytes of this asset entry's data. May be
{@link #UNKNOWN_LENGTH} if the asset extends to the end of the file.
If the AssetFileDescriptor was constructed with {@link #UNKNOWN_LENGTH},
this will use {@link ParcelFileDescriptor#getStatSize()
ParcelFileDescriptor.getStatSize()} to find the total size of the file,
returning that number if found or {@link #UNKNOWN_LENGTH} if it could
not be determined.
if (mLength >= 0) {
return mLength;
}
long len = mFd.getStatSize();
return len >= 0 ? len : UNKNOWN_LENGTH;
|
public android.os.ParcelFileDescriptor | getParcelFileDescriptor()The AssetFileDescriptor contains its own ParcelFileDescriptor, which
in addition to the normal FileDescriptor object also allows you to close
the descriptor when you are done with it.
return mFd;
|
public long | getStartOffset()Returns the byte offset where this asset entry's data starts.
return mStartOffset;
|
public java.lang.String | toString()
return "{AssetFileDescriptor: " + mFd
+ " start=" + mStartOffset + " len=" + mLength + "}";
|
public void | writeToParcel(android.os.Parcel out, int flags)
mFd.writeToParcel(out, flags);
out.writeLong(mStartOffset);
out.writeLong(mLength);
if (mExtras != null) {
out.writeInt(1);
out.writeBundle(mExtras);
} else {
out.writeInt(0);
}
|