J2ME中文教程 7 开发无线网络应用程序[34]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

  tf = new TextField("Send:", "", 30, TextField.ANY);

  f.append(si);

  f.append(tf);

  f.addCommand(exitCommand);

  f.addCommand(sendCommand);

  f.setCommandListener(this);

  display.setCurrent(f);

 }

 /**

  * Start the client thread

  */

 public void start() {

  Thread t = new Thread(this);

  t.start();

 }

 public void run() {

  try {

   sc = (SocketConnection) Connector.open("socket://localhost:5009");

   si.setText("Connected to server");

   is = sc.openInputStream();

   os = sc.openOutputStream();

   // Start the thread for sending messages - see Sender's main

   // comment for explanation

   sender = new Sender(os);

   // Loop forever, receiving data

   while (true) {

    StringBuffer sb = new StringBuffer();

    int c = 0;

    while (((c = is.read()) != '\n') && (c != -1)) {

     sb.append((char) c);

本文关键:J2ME中文教程 7 开发无线网络应用程序
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top