⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workthread.java

📁 手机Java开发教材的源代码:1.商用建构流程(WTK104)
💻 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 + -