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

📄 httptest.java

📁 J2ME开发实例,内含有可运行的实例代码!
💻 JAVA
字号:
//HTTPTest.java
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.* ;
import java.io.*;
public class HTTPTest extends MIDlet
{
	private Display display;

	public void startApp()
	{
		display = Display.getDisplay(this);
		try
		{
			//String url = "http://localhost:80/postinfo.html" ;
			String url = "http://e.pku.edu.cn";
			HttpConnection hc = (HttpConnection)
				Connector.open(url) ;

			DataInputStream dis =
				new DataInputStream(hc.openInputStream()) ;
			String content = "" ;
			int ic ;
			while( (ic = dis.read()) != -1 )
			{
				content = content + (char)ic ;
			}
			Form f = new Form("HTTP Test");
			f.append(content) ;
			display.setCurrent(f) ;
		}
		catch(Exception e)
		{
			System.out.println(e.getMessage()) ;
			notifyDestroyed() ;
		}
	}
	public void pauseApp()
	{}
	public void destroyApp(boolean unconditional)
	{}
}

⌨️ 快捷键说明

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