?? workthread.java
字號:
import javax.microedition.io.*;
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class WorkThread extends Thread
{
String url ;
Display display ;
public WorkThread(String url,Display d)
{
this.url = url ;
display = d ;
System.out.println("準(zhǔn)備連接:"+this.url) ;
}
public void run()
{
HttpConnection conn = null;
InputStream is = null;
InputStreamReader isr = null ;
StringBuffer line = new StringBuffer("");
try {
conn = (HttpConnection)Connector.open(url);
System.out.println("內(nèi)容長度:" + conn.getLength()) ;
is = conn.openInputStream();
isr = new InputStreamReader(is) ;
int ic ;
while( (ic = isr.read()) != -1 )
{
line.append((char)ic) ;
}
}catch (Exception ioe)
{
System.out.println(ioe);
}finally
{
try
{
if(conn!=null)
conn.close();
}catch(Exception e){}
}
Alert al = new Alert("查詢結(jié)果",line.toString(),null,AlertType.CONFIRMATION);
al.setTimeout(Alert.FOREVER) ;
display.setCurrent(al) ;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -