?? workthread.java
字號:
import javax.microedition.io.*;
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class WorkThread extends Thread
{
String qs ;
Display display ;
public WorkThread(String qs,Display d)
{
this.qs = qs ;
display = d ;
System.out.println("準備送出查詢字符串:"+this.qs) ;
}
public void run()
{
String url = "socket://127.0.0.1:8189" ;
SocketConnection conn = null;
InputStream is = null;
OutputStream os = null ;
DataInputStream dis = null ;
DataOutputStream dos = null ;
String line = "";
try {
conn = (SocketConnection)Connector.open(url);
is = conn.openInputStream();
os = conn.openOutputStream();
dis = new DataInputStream(is) ;
dos = new DataOutputStream(os) ;
//送出查詢字符串
dos.writeUTF(qs) ;
dos.flush() ;
//取得結果字符串
while(true)
{
line = line + dis.readUTF() ;
System.out.println(line) ;
}
}catch (Exception ioe)
{
}finally
{
try
{
if(conn!=null)
conn.close();
}catch(Exception e){}
}
Alert al = new Alert("查詢結果",line,null,AlertType.CONFIRMATION);
al.setTimeout(Alert.FOREVER) ;
display.setCurrent(al) ;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -