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

📄 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 url ;
	Display display ;
	public WorkThread(String url,Display d)
	{
		this.url = url ;
		display = d ;
		System.out.println("准备连接:"+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("内容长度:" + 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("查询结果",line.toString(),null,AlertType.CONFIRMATION);
 		al.setTimeout(Alert.FOREVER) ;
 		display.setCurrent(al) ;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -