📄 updateuserdatathread.java
字号:
import javax.microedition.io.*;
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.* ;
public class UpdateUserDataThread extends Thread
{
String url ;
public UpdateUserDataThread(String url,String id,String pw,String ds)
{
String enc = System.getProperty("microedition.encoding") ;
System.out.println("系统使用的编码:"+enc) ;
this.url = url+"?id="+id+"&pw="+pw+"&ds="+ds ;
System.out.println("准备连接:"+this.url) ;
}
public void run()
{
boolean error = false ;
HttpConnection c = null;
InputStream is = null;
OutputStream os = null;
DataInputStream dos = null ;
String line = "" ;
try
{
c = (HttpConnection)Connector.open(url);
System.out.println("回传码:" + c.getResponseCode()) ;
is = c.openInputStream();
dos = new DataInputStream(is) ;
line = dos.readUTF() ;
}catch (EOFException e)
{
System.out.println("接收到的响应:" + line) ;
}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 (is != null)
is.close();
if (os != null)
os.close();
if (c != null)
c.close();
}catch(Exception e){}
}
if(!error)
{
Alert al = new Alert("更新结果",line,null,AlertType.CONFIRMATION) ;
al.setTimeout(Alert.FOREVER) ;
Navigator.display.setCurrent(al) ;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -