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

📄 dirinput.java

📁 J2ME 无线通信技术应用开发源代码
💻 JAVA
字号:
//程序名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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -