/******************************************************************
* Copyright (C) 2002-2005, Andrew Girow. All rights reserved. *
* ---------------------------------------------------------------*
* This software is published under the terms of the TinyLine *
* License version 1.8, a copy of which has been included *
* with this distribution in the TINYLINE_LICENSE file. *
*****************************************************************/
/**
* Create the progress form and gauge. This program is not interactive, it
* will exit when done.
*/
public GZIPTest() {
gauge = new Gauge("Progress", false, 10, 0);
form = new Form("Progress");
form.append(gauge);
Display.getDisplay(this).setCurrent(form);
}
/**
* Start a thread to run.
*/
public void startApp() {
new Thread(this).start();
}
/**
* Run the examples.
*/
public void run() {
try {
gauge.setLabel("Get using ContentConnection");
gauge.setValue(2);
getViaContentConnection(url);
getViaContentConnection(url2);
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
gauge.setValue(10);
notifyDestroyed();
}
public void pauseApp() {
}
/**
* Destroy must cleanup everything. The thread is signaled to stop and no
* result is produced.
*
* @param unconditional
* true if forced shutdown.
*/
public void destroyApp(boolean unconditional) {
}
void getViaContentConnection(String url) throws IOException {
ContentConnection c = null;
InputStream is = null;
GZIPInputStream gis = null;
byte[] buf = new byte[512];
int len;
try {
c = (ContentConnection) Connector.open(url);
is = c.openInputStream();
// If the url ends with svgz then use the
// GZIPInputStream
if (url.endsWith("svgz")) {
// Open the GZIPInputStream the regular way
is = new GZIPInputStream(is);
}
long t0, t1; // time stamps
t0 = System.currentTimeMillis();
// Read the gzip archive.
while ((len = is.read(buf)) >= 0) {
// Print the content if you want
// System.out.println(""+ new String(buf));
}
t1 = System.currentTimeMillis();
System.out.println(url + " elapsed time: " + (t1 - t0));
} finally {
if (is != null)
is.close();
if (c != null)
c.close();
}
}
}
正在通过存储根 DefaultColorPhone 来运行
Running with locale: Chinese_People's Republic of China.936
java.lang.NoClassDefFoundError: com/tinyline/util/GZIPInputStream
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+116)
Execution completed.
3417243 bytecodes executed
30 thread switches
1647 classes in the system (including system classes)
17816 dynamic objects allocated (534464 bytes)
3 garbage collections (460336 bytes collected)