📄 sendlongtext.java~1~
字号:
import java.io.File;import java.io.IOException;import com.objectxp.msg.GsmSmsService;import com.objectxp.msg.MessageException;import com.objectxp.msg.SmsService;import com.objectxp.msg.ems.EMSMessage;import com.objectxp.msg.ems.EMSText;/** * This class demonstrates how to send multipart (concatenated) * messages using jSMS. * * To send concatenated Messages, the EMSMessage class can be used. jSMS * automatically splits messages longer than 160 characters into multiple * fragments and constructs the required SMS User Data Header. * * Please note that most mobile phones today support multipart-messages, * therefore it is save to use EMSMessage even for mobile phones not supporting * EMS. However, any EMS specific message elements (e.g. text formatting) * will not be displayed correctly on these phones. * **/public class SendLongText{ private static String longText = "A mobile phone, also known as a cellular phone or cell phone, is a " + "portable electronic device which behaves as a normal telephone whilst " + "being able to move over a wide area. Mobile phones allow " + "connections to be made to the telephone network, normally by directly " + "dialing the other party's number on an inbuilt keypad. Most current " + "mobile phones use a combination of radio wave transmission and conventional " + "telephone circuit switching, though packet switching is already in use for " + "some parts of the mobile phone network, especially for services such as " + "Internet access and WAP."; public static void main(String args[]) throws IOException, MessageException { if(args.length != 2 ) { System.err.println("Usage: SendLongText <config-file> <recipient>"); System.exit(1); } // Create and initialize the SmsService (Replace GsmSmsService with // the SmsService Implementation of your choice). SmsService service = new GsmSmsService(); service.init(new File(args[0])); // create EMSMessage with long text File configFile = new File(args[0]); EMSMessage emsMsg = new EMSMessage(); EMSText emsText = new EMSText(longText); emsMsg.add(emsText); emsMsg.setRecipient(args[1]); // connect, send message and disconnect try { service.connect(); service.sendMessage(emsMsg); service.disconnect(); } finally { service.destroy(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -