dirinput.java

来自「J2ME 无线通信技术应用开发源代码」· Java 代码 · 共 29 行

JAVA
29
字号
//程序名DirInput.java,项目DirInput
//测试从Connector类直接获得InputStream
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import java.io.*;
public class DirInput extends MIDlet {
InputStream is = null;

  public void startApp() {
    try {
      String url ="http://localhost:8080/j2me/html/TestConnection.html";
      is = Connector.openInputStream(url);
      int ch;
      while ((ch = is.read()) != -1) {
        System.out.print((char)ch);
      }
      if (is != null) 
        is.close();
    } catch( ConnectionNotFoundException e ){
      System.out.println( "Http could not be opened" );
      } catch (IOException e) {
      System.out.println("other error.");
    }
    notifyDestroyed();//测试完毕后关闭应用程序
  }
  
  public void pauseApp() {}
  public void destroyApp( boolean unconditional ) {}
}

⌨️ 快捷键说明

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