选择显示字体大小

使用proguard混淆j2me应用程序

import javax.microedition.midlet.midlet;
import javax.microedition.midlet.midletstatechangeexception;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;

public class imagegetter extends midlet implements commandlistener
{

private display display;
public static final command conncommand = new command("connect",
command.item, 1);
public static final command exitcommand = new command("exit", command.exit,
1);
private form mainform;
private getterthread gt;

protected void startapp() throws midletstatechangeexception
{

display = display.getdisplay(this);
mainform = new form("image getter");
mainform.append("click connect to get image");
mainform.addcommand(conncommand);
mainform.addcommand(exitcommand);
mainform.setcommandlistener(this);
display.setcurrent(mainform);
gt = new getterthread(this);
gt.start();

}

public void setimage(image image)
{

mainform.append(image);
display.setcurrent(mainform);
}

protected void pauseapp()
{

}

protected void destroyapp(boolean arg0) throws midletstatechangeexception
{

}

public void commandaction(command cmd, displayable disp)
{
if (cmd == conncommand)
{
synchronized (this)
{
notify();
}
} else if (cmd == exitcommand)
{
exitmidlet();
}
}

private void exitmidlet()
{
try
{
destroyapp(false);
notifydestroyed();
} catch (midletstatechangeexception e)
{
e.printstacktrace();
}
}

class getterthread extends thread
{
private imagegetter midlet;
public static final string url = "http://localhost/j2medev.png";
private httpconnection httpconn = null;
private inputstream is = null;

public getterthread(imagegetter midlet)
{
this.midlet = midlet;
}

public void run()
{
synchronized (midlet)
{
try
{
midlet.wait();
} catch (interruptedexception e)
{
e.printstacktrace();
}
}
system.out.println("connect to server...");
try
{
httpconn = (httpconnection) connector.open(url);
is = httpconn.openinputstream();
bytearrayoutputstream baos = new bytearrayoutputstream();
int ch = 0;
while ((ch = is.read()) != -1)
{
baos.write(ch);
}
byte[] imagedata = baos.tobytearray();
image image = image.createimage(imagedata, 0, imagedata.length);
midlet.setimage(image);
baos.close();
is.close();
httpconn.close();

} catch (ioexception e)
{
e.printstacktrace();
}

}
}

}

右键选择项目getimage-j2me-create obfuscated package,这样proguard就会把除midlet之外的class文件混淆。如下图所示:

在deploy文件夹内我们可以看到getimage.jar、getimage.jad和一些proguard产生的其他文件,你可以用jar命令解开getimage.jar,发现他的另一个class文件已经被混淆成a.class了,midlet类则没有任何改变,proguard除了混淆的功能之外同时会把我们的jar文件减小,提高一些运行效率。


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons