import java.io.DataInputStream;
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
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.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.Ticker;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class Apprance extends MIDlet implements CommandListener{
private Display dis;
private Form f;
private TextField inputCity,inputStart,inputEnd;
private Command sendc,exitc;
public Apprance() {
f=new Form("");
inputCity=new TextField("City:","",20,TextField.ANY);
inputStart=new TextField("Start:","",20,TextField.ANY);
inputEnd=new TextField("End:","",20,TextField.ANY);
sendc=new Command("Send",Command.OK,1);
exitc=new Command("Exit",Command.CANCEL,1);
f.setTicker(new Ticker("欢迎使用移动公交查询系统!"));
f.append("输入查找信息:");
f.append(inputCity);
f.append(inputStart);
f.append(inputEnd);
f.addCommand(sendc);
f.addCommand(exitc);
f.setCommandListener(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
dis=Display.getDisplay(this);
dis.setCurrent(f);
}
public void commandAction(Command c, Displayable s) {
if(c==sendc)
{
new connectServer().start();
}
}
// 连接服务器
class connectServer extends Thread
{
public void run()
{
try{
String sinputCity=inputCity.getString();
String sinputStart=inputStart.getString();
String sinputEnd=inputEnd.getString();
String url="http://localhost:8080/result.jsp";
HttpConnection hc=(HttpConnection)Connector.open(url);
System.out.println("连接的状态是:"+hc.getResponseMessage());
DataInputStream dis=hc.openDataInputStream();//这个流其实是将jsp页面上的东西转化的流
int len=(int)hc.getLength();//创建一个字节数组用来承载流
byte[] b=new byte[len];
dis.read(b);//将流读到此数组中去
String str=new String(b);
f.append(str);
}catch(Exception e)
{
e.printStackTrace();
}
}
}
}
政府行政事业机关单位网站管理系统正式版
需积分: 4 150 浏览量
2011-03-23
22:07:51
上传
评论
收藏 98KB RAR 举报
huangyinge
- 粉丝: 9
- 资源: 5
最新资源
- IMG_20240423_191216.jpg
- 基于MATLAB实现分析黑体辐射光谱图时将通过迈克尔逊干涉仪得到干涉图经过傅里叶变换转换为光谱图的功能源码.zip
- DynamicArray02.java
- 数据可视化 matplotlib 实例.docx
- 数据可视化 matplotlib 实例.7z
- Python 使用 Matplotlib 绘制甘特图的实践.7z
- Python 使用 Matplotlib 绘制甘特图的实践.docx
- matplotlib 中的 cmap 参数介绍.docx
- matplotlib 中的 cmap 参数介绍.7z
- 基于matlab的毕业设计基于Matlab使用LQR实现车辆轨迹跟踪源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈