S60SDK中如何对文件进行压缩?

码工码工 2008-02-19 04:07:05
现在有这样一个需求:在S60平台上,先生成文件,然后再对文件进行压缩,再发送给服务器,这里的文件压缩如何实现?
...全文
107 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
朵朵码爸爸 2009-03-24
  • 打赏
  • 举报
回复
我也遇到同样的问题,可能是类本身的问题,因为抱出该错误,有可能是在实例化的时候,或者在static{}的时候。我也正为此发愁,网上怎么也找不到开源的。不知道楼主是否已经解决这个问题,希望能加以指点,多谢~
码工码工 2008-02-20
  • 打赏
  • 举报
回复

报上边异常的MIDlet:

/******************************************************************
* 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. *
*****************************************************************/

package src;

import java.io.*;
import javax.microedition.io.Connector;
import javax.microedition.io.ContentConnection;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.HttpConnection;

import javax.microedition.lcdui.Gauge;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Display;

import javax.microedition.midlet.*;

// Import GZIPInputStream class
import com.tinyline.util.GZIPInputStream;

/**
* GZIPTest is a sample MIDlet that uses GZIPInputStream.
*/
public class GZIPTest extends MIDlet implements Runnable {

/** The example URLs. It is the same SVG content. */
String url = "http://www.tinyline.com/demo/svg/roadmap.svg";

String url2 = "http://www.tinyline.com/demo/svg/roadmap.svgz";

Gauge gauge;

Form form;

/**
* 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();
}
}
}
码工码工 2008-02-20
  • 打赏
  • 举报
回复
哈,不会吧,一个回复都没有?

大家给个解决办法,我从网上看资料,tinyline的GZIPInputStream可以进行压缩。只是我明明加载了jar文件,可硬是说找不到类,报如下异常:

正在通过存储根 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)

我已经把jar包加进了项目中。
大家有什么建议,提一下。

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧