httpexample.java

来自「j2me实例代码」· Java 代码 · 共 72 行

JAVA
72
字号
package ConnectionImpl;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.io.*;
import java.io.*;
import javax.microedition.io.*;
import java.util.*;
import javax.microedition.lcdui.*;
public class HttpExample extends MIDlet implements CommandListener{

	private Command exit,start;
	private Display display;
	private Form form;
	private StringItem stars;
	
	public HttpExample() {
		super();
		display=Display.getDisplay(this);
		exit=new Command("Exit",Command.EXIT,1);
		start=new Command("start",Command.EXIT,1);
		form=new Form("Customer Ranking");
		form.addCommand(exit);
		form.addCommand(start);
		form.setCommandListener(this);
		String str=System.getProperty("microedition.commports");
		System.out.println(str);
	}

	protected void startApp() throws MIDletStateChangeException {
		display.setCurrent(form);

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	public void commandAction(Command c, Displayable d) {
		/*if(c==start){
			System.out.println("ccccccccccccc");
			StreamConnection connection=null;
			InputStream in=null;
			StringBuffer buffer=new StringBuffer();
			try{
				connection=(StreamConnection)Connector.open("http://www.baidu.com");
				in=connection.openInputStream();
				int ch;
				System.out.println("aaaaaaaaaaaaaa");
				while((ch=in.read())!=-1){
					System.out.println("this is"+ch);
				}
				System.out.println("dddddddddddddd");
			}catch(IOException e){
				System.out.println(buffer.toString());
				
			}
		}
		*/
	}

}

⌨️ 快捷键说明

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