byte[] cache = new byte[1024];  URLConnection conn = midletSource.openConnection(); JarInputStream jis = new JarInputStream(conn.getInputStream()); while (true) { JarEntry entry = jis.getNextJarEntry(); if (entry != null) { if (!entry.isDirectory()) { int offset = 0; int i = 0; while ((i = jis.read(cache, offset, cache.length - offset)) != -1) { offset += i; if (offset >= cache.length) { byte newcache[] = new byte[cache.length + 1024]; System.arraycopy(cache, 0, newcache, 0, cache.length); cache = newcache; } } byte[] tmp = new byte[offset]; System.arraycopy(cache, 0, tmp, 0, offset); entries.put(entry.getName(), tmp); } } else { break; }
String path = midletSource.toExternalForm(); if (path.endsWith(".jar")) { addJarURL(midletSource); } else if (path.startsWith("file:")) { addPathURL(midletSource); } else { throw new IOException("URL Type not supported: " + midletSource);
	public void addURL(URL midletSource) throws IOException {		byte[] cache = new byte[1024];		URLConnection conn = midletSource.openConnection();		JarInputStream jis = new JarInputStream(conn.getInputStream());		while (true) {			JarEntry entry = jis.getNextJarEntry();			if (entry != null) {				if (!entry.isDirectory()) {					int offset = 0;					int i = 0;					while ((i = jis.read(cache, offset, cache.length							- offset)) != -1) {						offset += i;						if (offset >= cache.length) {							byte newcache[] = new byte[cache.length + 1024];							System.arraycopy(cache, 0, newcache, 0,									cache.length);							cache = newcache;						}					}					byte[] tmp = new byte[offset];					System.arraycopy(cache, 0, tmp, 0, offset);					entries.put(entry.getName(), tmp);				}			} else {				break;			}		}	}