📄 receivesms.java
字号:
package dk.daimi.jones.app.smsdemo;
import dk.daimi.jones.services.sms.*;
import dk.daimi.jones.impl.sms.*;
/**
* @author Jonas Thomsen
*
* Receives incomming SMSs and displays them on the screen.
*
*/
public class ReceiveSMS {
public static void main(String[] args) {
// Anonousmus class for implementing the NMIListener interface
NMIListener myNMIListener = new NMIListener() {
public void messageReceived(SMSMessage smsMessage) {
System.out.println("Received SMS from '" + smsMessage.getAddress() + "'");
System.out.println("Text: '" + smsMessage.getData() + "'");
}
};
SMS sms = new SMSImpl();
System.out.print("Starting SMS service... ");
if (((SMSImpl)sms).open("COM1", "")) {
System.out.println("Done!");
System.out.println("Press Ctrl+C to end the program.");
// Register reception of incomming messages with the framework
sms.addNMIListener(myNMIListener);
// Keep the application running so we can see the result
try {
while (true) {
Thread.sleep(10000);
}
} catch( Exception e ) {}
} else {
System.out.println("Failed!");
}
((SMSImpl)sms).close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -