|
Android 2.3 Gingerbread | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.content.res.AssetFileDescriptor
public class AssetFileDescriptor
File descriptor of an entry in the AssetManager. This provides your own opened FileDescriptor that can be used to read the data, as well as the offset and length of that entry's data in the file.
| Nested Class Summary | |
|---|---|
static class |
AssetFileDescriptor.AutoCloseInputStream
An InputStream you can create on a ParcelFileDescriptor, which will take care of calling ParcelFileDescritor.close() for you when the stream is closed. |
static class |
AssetFileDescriptor.AutoCloseOutputStream
An OutputStream you can create on a ParcelFileDescriptor, which will take care of calling ParcelFileDescritor.close() for you when the stream is closed. |
| Nested classes/interfaces inherited from interface android.os.Parcelable |
|---|
Parcelable.Creator<T> |
| Field Summary | |
|---|---|
static Parcelable.Creator<AssetFileDescriptor> |
CREATOR
|
static long |
UNKNOWN_LENGTH
Length used with AssetFileDescriptor(ParcelFileDescriptor, long, long)
and getDeclaredLength() when a length has not been declared. |
| Fields inherited from interface android.os.Parcelable |
|---|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE |
| Constructor Summary | |
|---|---|
AssetFileDescriptor(Parcel src)
|
|
AssetFileDescriptor(ParcelFileDescriptor fd,
long startOffset,
long length)
Create a new AssetFileDescriptor from the given values. |
|
| Method Summary | |
|---|---|
void |
close()
Convenience for calling getParcelFileDescriptor().close(). |
FileInputStream |
createInputStream()
Create and return a new auto-close input stream for this asset. |
FileOutputStream |
createOutputStream()
Create and return a new auto-close output stream for this asset. |
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation. |
static AssetFileDescriptor |
fromMemoryFile(MemoryFile memoryFile)
Creates an AssetFileDescriptor from a memory file. |
long |
getDeclaredLength()
Return the actual number of bytes that were declared when the AssetFileDescriptor was constructed. |
FileDescriptor |
getFileDescriptor()
Returns the FileDescriptor that can be used to read the data in the file. |
long |
getLength()
Returns the total number of bytes of this asset entry's data. |
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. |
long |
getStartOffset()
Returns the byte offset where this asset entry's data starts. |
String |
toString()
Returns a string containing a concise, human-readable description of this object. |
void |
writeToParcel(Parcel out,
int flags)
Flatten this object in to a Parcel. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final long UNKNOWN_LENGTH
AssetFileDescriptor(ParcelFileDescriptor, long, long)
and getDeclaredLength() when a length has not been declared. This means
the data extends to the end of the file.
public static final Parcelable.Creator<AssetFileDescriptor> CREATOR
| Constructor Detail |
|---|
public AssetFileDescriptor(ParcelFileDescriptor fd,
long startOffset,
long length)
fd - The underlying file descriptor.startOffset - The location within the file that the asset starts.
This must be 0 if length is UNKNOWN_LENGTH.length - The number of bytes of the asset, or
{@link #UNKNOWN_LENGTH if it extends to the end of the file.AssetFileDescriptor(Parcel src)
| Method Detail |
|---|
public ParcelFileDescriptor getParcelFileDescriptor()
public FileDescriptor getFileDescriptor()
public long getStartOffset()
public long getLength()
UNKNOWN_LENGTH if the asset extends to the end of the file.
If the AssetFileDescriptor was constructed with UNKNOWN_LENGTH,
this will use ParcelFileDescriptor.getStatSize() to find the total size of the file,
returning that number if found or UNKNOWN_LENGTH if it could
not be determined.
getDeclaredLength()public long getDeclaredLength()
UNKNOWN_LENGTH if the length was not declared, meaning data
should be read to the end of the file.
getDeclaredLength()
public void close()
throws IOException
getParcelFileDescriptor().close().
IOException
public FileInputStream createInputStream()
throws IOException
AssetFileDescriptor.AutoCloseInputStream, or
an underlying 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.
IOException
public FileOutputStream createOutputStream()
throws IOException
AssetFileDescriptor.AutoCloseOutputStream, or
an underlying 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.
IOExceptionpublic String toString()
ObjectgetClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful toString method
if you intend implementing your own toString method.
toString in class Objectpublic int describeContents()
Parcelable
describeContents in interface Parcelable
public void writeToParcel(Parcel out,
int flags)
Parcelable
writeToParcel in interface Parcelableout - The Parcel in which the object should be written.flags - Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.
public static AssetFileDescriptor fromMemoryFile(MemoryFile memoryFile)
throws IOException
IOException
|
Android 2.3 Gingerbread | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||