FileDocCategorySizeDatePackage
JarReader.javaAPI DocJ2ME MIDP 2.02456Thu Nov 07 12:02:24 GMT 2002com.sun.midp.midletsuite

JarReader

public class JarReader extends Object
This class provides a Java API for reading an entry from a Jar file stored on the file system.

Fields Summary
Constructors Summary
Methods Summary
static byte[]readJarEntry(com.sun.midp.security.SecurityToken securityToken, java.lang.String jarFilePath, java.lang.String entryName)
Returns the content of the given entry in the JAR file on the file system given by jarFilePath.

param
securityToken token with permission to install software
param
jarFilePath file pathname of the JAR file to read. May be a relative pathname.
param
entryName name of the entry to return.
return
the content of the given entry in a byte array or null if the entry was not found
exception
IOException if JAR is corrupt or not found
exception
IOException if the entry does not exist.
exception
SecurityException if the caller does not have permission to install software.

        byte[] asciiFilename;
        byte[] asciiEntryName;

        securityToken.checkIfPermissionAllowed(Permissions.AMS);

        asciiFilename = Util.toCString(jarFilePath);
        asciiEntryName = Util.toCString(entryName);

        return readJarEntry0(asciiFilename, asciiEntryName);
    
private static native byte[]readJarEntry0(byte[] localJarFilePath, byte[] localEntryName)
Performs the same function as readJarEntry, except file names are passed in localized characters (so that unicode -> "C" string conversion does not need to happen inside native code).

param
localJarFilePath file pathname of the JAR file to read. May be a relative pathname.
param
localEntryName name of the entry to return.
return
the content of the given entry in a byte array or null if the entry was not found
exception
IOException if JAR is corrupt or not found