smsserver.java
来自「一个sms 客户端和服务器端的例子」· Java 代码 · 共 55 行
JAVA
55 行
package sms;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.io.*;import javax.wireless.messaging.*;public class SMSServer extends MIDlet { protected Display display; protected Displayable displayable; protected Form form; public SMSServer() { display = Display.getDisplay(this); displayable = form = new Form("SMS 服务器"); } public void startApp() { display.setCurrent(displayable); try { String addr = "sms://:5432"; MessageConnection conn = (MessageConnection) Connector.open(addr); Message msg = null; while (true) { //接收文本信息 msg = conn.receive(); // 接收信息 if (msg instanceof TextMessage) { TextMessage tmsg = (TextMessage) msg; String receivedText = tmsg.getPayloadText(); form.append(new TextField("收到文本信息", receivedText, 20, TextField.ANY)); } else if (msg instanceof BinaryMessage) { //接收资金信息 BinaryMessage bmsg = (BinaryMessage) msg; String receivedMsg = new String(bmsg.getPayloadData()); form.append(new TextField("收到字节信息", receivedMsg, 20, TextField.ANY)); } } } catch (Exception e) { System.out.println(e.toString()); } } public void pauseApp() { } public void destroyApp(boolean unconditional) { display = null; displayable = null; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?