sender.java

来自「一个发送短信和接受短信的代码!忽忽忽忽户忽忽忽忽!」· Java 代码 · 共 58 行

JAVA
58
字号
package fourconnect;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */import javax.microedition.lcdui.*;import javax.microedition.midlet.*;import javax.microedition.io.*;import java.io.*;public class Sender extends Thread {	private OutputStream os;	public String message;	public Sender(OutputStream os) {		this.os = os;		start();	}	public synchronized void send(String msg) {		message = msg;		notify();	}	public synchronized void run() {		while (true) {			if (message == null) {				try {					wait();				} catch (InterruptedException e) {				}			}			if (message == null)				break;			try {				os.write(message.getBytes());				os.write("\n".getBytes());			} catch (IOException ioe) {				System.out.println("错误:" + ioe.getMessage());			}			message = null;		}	}	public synchronized void stop() {		message = null;		notify();	}}

⌨️ 快捷键说明

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