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

📄 workthread.java

📁 j2me实例代码
💻 JAVA
字号:
package httpsample;

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;
	}
	public void run(){
		HttpConnection conn=null;
		InputStream is=null;
		InputStreamReader isr=null;
		StringBuffer line =new StringBuffer("");
		try{
			conn=(HttpConnection)Connector.open(url);
			is=conn.openInputStream();
			isr=new InputStreamReader(is);
			int ic;
			while((ic=isr.read())!=-1){
				line.append((char)ic);
			}
		}catch(Exception e){
			
		}finally{
			try{
				if(conn!=null)
					conn.close();
				
			}catch(Exception e){}
		}
		Alert al=new Alert("query result:",line.toString(),null,AlertType.CONFIRMATION);
		al.setTimeout(Alert.FOREVER);
		display.setCurrent(al);
	}
}

⌨️ 快捷键说明

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