testhttp.java

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

JAVA
25
字号
//程序名TestHTTP.java;
import java.io.*;
import javax.microedition.io.*;
public class TestHTTP {
  public static void main( String[] args ){
    try {
      String uri ="http://127.0.0.1/test.html";
      ContentConnection conn = (ContentConnection)Connector.open( uri );
      InputStream in = conn.openInputStream();
      int ch;
      System.out.println( "Content type is " + conn.getType() );
      while( ( ch = in.read() ) != -1 ){
        System.out.print( (char) ch );
      }
      in.close();
      conn.close();
    } catch( ConnectionNotFoundException e ){
      System.out.println("URI could not be opened" );
    } catch( IOException e ){
      System.out.println( e.toString() );
    }
    System.exit( 0 );
  }
}

⌨️ 快捷键说明

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