Android
dalvik.system
public final class

dalvik.system.DexFile

java.lang.Object
dalvik.system.DexFile

Manipulate DEX files. Similar in principle to java.util.zip.ZipFile. Used primarily by class loaders. We don't directly open and read the DEX file here. They're mapped read-only by the VM.

Summary

Public Constructors

            DexFile(File file)
Open a DEX file from a File object.
            DexFile(String fileName)
Open a DEX file from a filename (preferrably a full path).

Public Methods

          void  close()
Close a DEX file.
          Enumeration<String entries()
Enumerate the names of the classes in this DEX file.
          String  getName()
Get the name of the open file.
          Class  loadClass(String name, ClassLoader loader)
Load a class.

Protected Methods

          void  finalize()
GC helper.
Methods inherited from class java.lang.Object

Details

Public Constructors

public DexFile(File file)

Open a DEX file from a File object.

Throws

IOException

public DexFile(String fileName)

Open a DEX file from a filename (preferrably a full path). This will usually be a Zip/Jar with a "classes.dex" inside. Do not specify the "dalvik-cache" version directly.

Throws

IOException

Public Methods

public void close()

Close a DEX file. This may not be able to release any resources. If classes have been loaded, the underlying storage can't be discarded.

Throws

IOException

public Enumeration<String> entries()

Enumerate the names of the classes in this DEX file.

public String getName()

Get the name of the open file.

public Class loadClass(String name, ClassLoader loader)

Load a class. Returns the class on success, or a null reference on failure. If you are not calling this from a class loader, this is most likely not going to do what you want. Use Class.forName() instead. "name" should look like "java/lang/String". I'm not throwing an exception if the class isn't found because I don't want to be throwing exceptions wildly every time we load a class that isn't in the first DEX file we look at. This method *will* throw exceptions for anything that isn't ClassNotFoundException.

Protected Methods

protected void finalize()

GC helper.

Throws

IOException
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56