- 1、本文档共9页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
不但有登陆设计,而将用户输入转换为其他编码类型,避
这是一个简单的但也是最为标准的网络客户端范例,不但有登陆设计,而且将用户输入转换为其他编码类型,避免的传送中被人截获数据盗取密码的危险。并且将用户所用手机信息版本全部发送给了服务端,有利于服务端人性化的因机而异。
A simple network client
/*?*?Copyright?(c)?2000-2001?Sun?Microsystems,?Inc.?All?Rights?Reserved.?*/import?java.lang.*;import?java.io.*;import?java.util.*;import?javax.microedition.io.*;import?javax.microedition.lcdui.*;import?javax.microedition.midlet.*;/**?*?A?simple?network?client.?*?*?This?MIDlet?shows?a?simple?use?of?the?HTTP?*?networking?interface.?It?opens?a?HTTP?POST?*?connection?to?a?server,?authenticates?using?*?HTTP?Basic?Authentication?and?writes?a?string?*?to?the?connection.?It?then?reads?the?*?connection?and?displays?the?results.?*/public?class?NetClientMIDlet?extends?MIDlet????implements?CommandListener?{????private?Display?display;??//?handle?to?the?display????private?Form?mainScr;?????//?main?screen????private?Command?cmdOK;????//?OK?command????private?Command?cmdExit;??//?EXIT?command????private?Form?dataScr;?????//?for?display?of?results????/**?????*?Constructor.?????*?????*?Create?main?screen?and?commands.?Main?????*?screen?shows?simple?instructions.?????*/????public?NetClientMIDlet()?{????????display?=?Display.getDisplay(this);????????mainScr?=?new?Form(NetClient);????????mainScr.append(Hit?OK?to?make?network?connection);????????mainScr.append(?);????????mainScr.append(Hit?EXIT?to?quit);????????cmdOK?=?new?Command(OK,?Command.OK,?1);????????cmdExit?=?new?Command(Exit,?Command.EXIT,?1);????????mainScr.addCommand(cmdOK);????????mainScr.addCommand(cmdExit);????????mainScr.setCommandListener(this);????}????/**?????*?Called?by?the?system?to?start?our?MIDlet.?????*?Set?main?screen?to?be?displayed.?????*/????protected?void?startApp()?{????????display.setCurrent(mainScr);????}????/**?????*?Called?by?the?system?to?pause?our?MIDlet.?????*?No?actions?required?by?our?MIDLet.?????*/????protected?void?pauseApp()?{}????/**?????*?Called?by?the?system?to?end?our?MIDlet.?????*?No?actions?requi
文档评论(0)