⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendunicodemessage.java

📁 控制手机发送短信程序
💻 JAVA
字号:
package sms;

import java.io.File;
import java.io.IOException;

import com.objectxp.msg.GsmSmsService;
import com.objectxp.msg.MessageException;
import com.objectxp.msg.SmsMessage;
import com.objectxp.msg.SmsService;

/**
 * This example demonstrates how to send unicode messages using jSMS
 **/
public class SendUnicodeMessage
{
  public static void main(String[] args) throws IOException, MessageException
  {
    if(args.length != 2 ) {
      System.err.println("Usage: SendUnicodeMessage <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]));

    SmsMessage msg = new SmsMessage();
    msg.setRecipient(args[1]);
    String unicodeMsg = "Cyrillic Capital Letter Zhe: \u0416";
    msg.setUserData(unicodeMsg.getBytes("UTF-16BE"));
    msg.setCodingGroup(SmsMessage.DC_GROUP_GENERAL);
    msg.setAlphabet(SmsMessage.DC_UCS2);

    /* With some mobile networks, the message class may not be set, otherwise
       the message will not be delivered as UCS2. If this example doesn't work
       with your mobile network, uncomment the following statement */

    //msg.setMessageClass(SmsMessage.NO_CLASS);

    // connect, send message and disconnect
    try {
      service.connect();
      service.sendMessage(msg);
      service.disconnect();
    }
    finally {
      service.destroy();
    }
  }
}

⌨️ 快捷键说明

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