?? getuserdatathread.java
字號:
import javax.microedition.io.*;
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.* ;
public class GetUserDataThread extends Thread
{
String url ;
public GetUserDataThread(String url)
{
this.url = url ;
System.out.println("準備連接:"+this.url) ;
}
public void run()
{
boolean error = false ;
HttpConnection conn = null;
InputStream is = null;
DataInputStream dos = null ;
Vector data = new Vector() ;
try {
conn = (HttpConnection)Connector.open(url);
is = conn.openInputStream();
dos = new DataInputStream(is) ;
while(true)
{
String line = dos.readUTF() ;
parseAndInsert(data,line) ;
}
}catch (EOFException e)
{
}catch (Exception e)
{
error = true ;
Alert al = new Alert("聯機時期發生錯誤",e.toString(),null,AlertType.ALARM) ;
al.setTimeout(Alert.FOREVER) ;
Navigator.display.setCurrent(al) ;
}finally
{
try
{
if(conn!=null)
conn.close();
}catch(Exception e){}
}
if(!error)
{
Navigator.current = Navigator.USERDATA_SCREEN ;
Navigator.show(data) ;
}
}
public void parseAndInsert(Vector v,String s)
{
int i = s.indexOf(",") ;
String id = s.substring(0,i) ;
s = s.substring(i+1) ;
i = s.indexOf(",") ;
String ps = s.substring(0,i) ;
s = s.substring(i+1) ;
i = s.indexOf(";") ;
String ds = s.substring(0,i) ;
v.addElement(id+" / "+ps+" / "+ds);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -