The Answer to Life, the Universe, and Everything

Tuesday, October 03, 2006

Class JarInflater

This is the general method to read the image data from jar file.
In DoJa programming, there is a size limitation. In order to reduce the main program file size, at the initial launch of the application, we download the resource file. Then jar file would be better in terms of the usage of the network resource especially for mobile phones.

public static Image loadJarImage(int pos,String name){
DataInputStream in = null;
JarInflater ji = null;
MediaImage mi = null;
Image img = null;
byte[] b = null;
//Read the data from sp
in = Connector.openDataInputStream("scratchpad:///0;pos=" + pos);
b = new byte[(int)ji.getSize(name)];
in.readFully( b );
ji = new JarInflater(b);

mi = MediaManager.getImage(ji.getInputStream(name));
img = mi.getImage();
}catch (Exception ex){
return img;

No comments: