- 浏览: 602209 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (448)
- 字符串相关 (16)
- Struts2页面显示 (15)
- Hibernate错误记录 (6)
- linux命令 (2)
- java项目测试 (5)
- 个人作品 (10)
- hibernate应用 (15)
- struts1 (7)
- 数据库(除了hibernate) (42)
- J2ME/WAP (37)
- servlet/jsp (49)
- java桌面应用+java综合 (14)
- 服务器配置,报错解决 (24)
- Myeclipse配置,抛错解决 (8)
- linux (18)
- JavaScript+jquery+ajax (45)
- div css 页面设计 (16)
- 互联网综合运营 (14)
- 编程工具类 (3)
- 论文 报告 文献 (14)
- PHP (26)
- struts2 (9)
- spring (1)
- 我的IT生活 (14)
- Resin (6)
- java项目记录 (14)
- https安全 (11)
- 支付技术 (3)
最新评论
-
yihaijunyxr:
很好呀,我好久没用iteye了,今天找出两个帐号(yihaij ...
c/c++的监听tmlisten启动缓慢解决 -
yihaijun:
好像这不算是技术博客,是工作博客
c/c++的监听tmlisten启动缓慢解决 -
ml365:
后来还优化了webservice的前置框架,不用cxf,用了另 ...
c/c++的监听tmlisten启动缓慢解决 -
Jayliuying:
有点晚哈 但是也支持一下 楼主
java相关论文的参考文献【转】 -
gqsunrise:
...
我是项目经理,我的项目管理日记【20120229】
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.ContentConnection;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.TextBox;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
/**
* 在运行的TextBox输入框中输入一个图片的网址,下载到模拟器中
*
* 例如:在输入框中输入:www.baidu.com/img/logo.gif
*
* @author mao
*
*/
public class ViewImage extends MIDlet implements CommandListener {
private Display display;
private TextBox tbMain;
private Alert alStatus;
private Form fm;
private Command cmExit;
private Command cmView;
private Command cmBack;
private static final int ALERT_DISPLAY_TIME = 3000;
Image im = null;
public ViewImage() {
display = Display.getDisplay(this);
tbMain = new TextBox("输入图片地址:", "http://", 75, 0);
cmExit = new Command("退出", Command.EXIT, 1);
cmView = new Command("下载", Command.SCREEN, 2);
tbMain.addCommand(cmExit);
tbMain.addCommand(cmView);
tbMain.setCommandListener(this);
fm = new Form("");
cmBack = new Command("后退", Command.BACK, 1);
fm.addCommand(cmBack);
fm.setCommandListener(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
display.setCurrent(tbMain);
}
public void commandAction(Command c, Displayable s) {
if (c == cmExit) {
try {
destroyApp(false);
notifyDestroyed();
} catch (MIDletStateChangeException e) {
e.printStackTrace();
}
} else if (c == cmView) {
showAlert("下载中...", false, tbMain);
Download dl = new Download(tbMain.getString(), this);
dl.start();
} else if (c == cmBack) {
display.setCurrent(tbMain);
}
}
public void showImage(boolean flag) {
if (flag == false)
showAlert("下载失败...", true, tbMain);
else {
ImageItem ii = new ImageItem(null, im, ImageItem.LAYOUT_DEFAULT,
null);
if (fm.size() != 0)
fm.set(0, ii);
else
fm.append(ii);
showAlert("下载成功", true, fm);
}
}
public void showAlert(String msg, boolean modal, Displayable displayable) {
alStatus = new Alert("状态", msg, null, AlertType.INFO);
if (modal)
alStatus.setTimeout(Alert.FOREVER);
else
alStatus.setTimeout(ALERT_DISPLAY_TIME);
display.setCurrent(alStatus, displayable);
}
}
class Download implements Runnable {
private String url;
private ViewImage Midlet;
private boolean downloadSuccess = false;
public Download(String url, ViewImage Midlet) {
this.url = url;
this.Midlet = Midlet;
}
public void run() {
try {
getImage(url);
} catch (Exception e) {
System.err.println("Msg : " + e.toString());
}
}
public void start() {
Thread thread = new Thread(this);
try {
thread.start();
} catch (Exception e) {
}
}
private void getImage(String url) throws IOException {
System.out.println();
System.out.println("this is the url : " + url);
ContentConnection connection = (ContentConnection) Connector.open(url);
System.out.println("connection : " + connection);
DataInputStream iStrm = connection.openDataInputStream();
System.out.println("iStrm: " + iStrm);
ByteArrayOutputStream bStrm = null;
Image im = null;
try {
byte imageData[];
int length = (int) connection.getLength();
if (length != -1) {
imageData = new byte[length];
iStrm.readFully(imageData);
} else {
bStrm = new ByteArrayOutputStream();
int ch;
while ((ch = iStrm.read()) != -1)
bStrm.write(ch);
imageData = bStrm.toByteArray();
}
im = Image.createImage(imageData , 0 , imageData.length);
} finally {
if (connection != null)
connection.close();
if (iStrm != null)
iStrm.close();
if (bStrm != null)
bStrm.close();
}
if (im == null)
Midlet.showImage(false);
else {
Midlet.im = im;
Midlet.showImage(true);
}
}
}
import java.io.DataInputStream;
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.ContentConnection;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.TextBox;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
/**
* 在运行的TextBox输入框中输入一个图片的网址,下载到模拟器中
*
* 例如:在输入框中输入:www.baidu.com/img/logo.gif
*
* @author mao
*
*/
public class ViewImage extends MIDlet implements CommandListener {
private Display display;
private TextBox tbMain;
private Alert alStatus;
private Form fm;
private Command cmExit;
private Command cmView;
private Command cmBack;
private static final int ALERT_DISPLAY_TIME = 3000;
Image im = null;
public ViewImage() {
display = Display.getDisplay(this);
tbMain = new TextBox("输入图片地址:", "http://", 75, 0);
cmExit = new Command("退出", Command.EXIT, 1);
cmView = new Command("下载", Command.SCREEN, 2);
tbMain.addCommand(cmExit);
tbMain.addCommand(cmView);
tbMain.setCommandListener(this);
fm = new Form("");
cmBack = new Command("后退", Command.BACK, 1);
fm.addCommand(cmBack);
fm.setCommandListener(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
display.setCurrent(tbMain);
}
public void commandAction(Command c, Displayable s) {
if (c == cmExit) {
try {
destroyApp(false);
notifyDestroyed();
} catch (MIDletStateChangeException e) {
e.printStackTrace();
}
} else if (c == cmView) {
showAlert("下载中...", false, tbMain);
Download dl = new Download(tbMain.getString(), this);
dl.start();
} else if (c == cmBack) {
display.setCurrent(tbMain);
}
}
public void showImage(boolean flag) {
if (flag == false)
showAlert("下载失败...", true, tbMain);
else {
ImageItem ii = new ImageItem(null, im, ImageItem.LAYOUT_DEFAULT,
null);
if (fm.size() != 0)
fm.set(0, ii);
else
fm.append(ii);
showAlert("下载成功", true, fm);
}
}
public void showAlert(String msg, boolean modal, Displayable displayable) {
alStatus = new Alert("状态", msg, null, AlertType.INFO);
if (modal)
alStatus.setTimeout(Alert.FOREVER);
else
alStatus.setTimeout(ALERT_DISPLAY_TIME);
display.setCurrent(alStatus, displayable);
}
}
class Download implements Runnable {
private String url;
private ViewImage Midlet;
private boolean downloadSuccess = false;
public Download(String url, ViewImage Midlet) {
this.url = url;
this.Midlet = Midlet;
}
public void run() {
try {
getImage(url);
} catch (Exception e) {
System.err.println("Msg : " + e.toString());
}
}
public void start() {
Thread thread = new Thread(this);
try {
thread.start();
} catch (Exception e) {
}
}
private void getImage(String url) throws IOException {
System.out.println();
System.out.println("this is the url : " + url);
ContentConnection connection = (ContentConnection) Connector.open(url);
System.out.println("connection : " + connection);
DataInputStream iStrm = connection.openDataInputStream();
System.out.println("iStrm: " + iStrm);
ByteArrayOutputStream bStrm = null;
Image im = null;
try {
byte imageData[];
int length = (int) connection.getLength();
if (length != -1) {
imageData = new byte[length];
iStrm.readFully(imageData);
} else {
bStrm = new ByteArrayOutputStream();
int ch;
while ((ch = iStrm.read()) != -1)
bStrm.write(ch);
imageData = bStrm.toByteArray();
}
im = Image.createImage(imageData , 0 , imageData.length);
} finally {
if (connection != null)
connection.close();
if (iStrm != null)
iStrm.close();
if (bStrm != null)
bStrm.close();
}
if (im == null)
Midlet.showImage(false);
else {
Midlet.im = im;
Midlet.showImage(true);
}
}
}
http://www.java-cn.com/club/html/63/n-163-3.htmlj2me最佳联网方案终结版
用 J2ME 进行联网用 J2ME 进行联网http://www.ibm.com/developerworks/cn/java/wi-jio/
发表评论
-
什么是WAP网关?
2011-10-17 17:09 9801. 什么是WAP网关? WA ... -
判断用户通过手机访问wap还是电脑直接访问
2011-10-17 16:29 1942首先说最根本的解决 ... -
wap的全面解析!!
2011-10-17 16:29 16721. 开发WAP软件需要哪 ... -
j2me library failed to get library information[转]
2010-12-11 21:59 1099出現過類似問題,我是每次都用的run as...->ru ... -
j2me联网时候对于代理问题可能会出现的错误【转】
2010-12-11 11:30 740众所周知,CMWAP是一个网关,同时又是一个代理服务器,我 ... -
在无线J2ME设备上实现超文本传输协议【转】
2010-12-11 11:27 728随着越来越多手提电 ... -
J2ME使用Socket通过cmwap接入点访问安全HTTPS 2【转】
2010-12-11 11:26 1210新建一个Midp应用程序,在startApp中加入以下代码: ... -
J2ME使用Socket通过cmwap接入点访问安全HTTPS1 【转】
2010-12-11 11:25 1358这个问题是在我升级J2ME版XHTML浏览器的时候被引入的,我 ... -
wml教程 中文手册
2010-12-11 01:02 836http://www.g168.net/txt/wml/ ... -
j2me结合j2ee实现用户登陆功能-2【转】
2010-12-11 00:41 916服务器代码:LoginServlet:package co ... -
j2me结合j2ee实现用户登陆功能【转】
2010-12-11 00:40 807手机客户端代码:LoginForm:package com ... -
独立WAP交友网站趋势分析
2010-12-10 19:28 921从互联网开始,交友网 ... -
什么是WAP?wap技术简介(转)
2010-12-10 19:25 937程序员都在讨论Wireless(无线)技术,也就是常说到的WA ... -
j2me游戏开发:控制飞机移动(转)
2010-12-10 19:01 8581. 飞机plane是一个标准的plane。由三桢画面组成,: ... -
j2me游戏开发:工具类的完善(转)
2010-12-10 19:00 884虽然我们有了midp2.0的支持,但是有时还是需要一些辅助工具 ... -
J2ME程序教程,程序+讲解,很好的入门教程(转载) 【2】
2010-12-10 18:59 684J2ME RPG游戏边学边做(二) 1、public vo ... -
J2ME程序教程,程序+讲解,很好的入门教程(转载) 【1】
2010-12-10 18:58 1085J2ME RPG游戏边学边做(一) 笔者以前是做j2ee的 ... -
J2ME内存优化(转载)
2010-12-10 18:58 837Out momory 一阵天旋地转 ... -
PngMate使用教程2(转)
2010-12-10 18:57 825下面我们来换一张图片,街头霸王Ken,这张gif的帧数比较多, ... -
PngMate使用教程1(转)
2010-12-10 18:56 1258PngMate使用教程 JAVA手机网[www.cnjm.n ...
相关推荐
J2ME无线通信技术应用开发,手机编程.主要介绍了基于java的手机软件开发。
j2me无线通信技术应用开发j2me无线通信技术应用开发
本书从J2ME 2.0编程技术出发着重介绍了无线编程技术,本书假设你已经对Java语言比较热悉,并且是一名J2SE的开发工程师,当我们在本书中提到有关J2SE、J2EE或JDBC等宁眼时你应该了然于胸,而不是感到陌生。...
j2me 精通J2ME无线编程,关于j2me 移动开发的书
J2ME 无线设备编程J2ME 无线设备编程J2ME 无线设备编程J2ME 无线设备编程
j2me 不同运营商移动,电信,联通联网方案
J2ME无线开发工具包(共2个分卷).part1
J2ME无线开发工具包(共2个分卷).part2
J2ME无线设备编程 ,J2ME无线设备编程
手机软件开发入门教程,J2ME无线通信技术应用开发。基于java的开发教程。
j2me框架_用J2ME的通用联网框架开发联网.pdf
J2ME通用进度条,解决联网、线程操作等候问题