sendsmartvcard.java~1~

来自「控制手机发送短信程序」· JAVA~1~ 代码 · 共 46 行

JAVA~1~
46
字号
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.smart.VCard;/** * This example demonstrates how to send "Business Cards" using jSMS */public class SendSmartVCard {  public static void main(String args[]) throws IOException, MessageException  {    if(args.length != 2 ) {      System.err.println("Usage: SendSmartVCard <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]));    VCard card = new VCard();    card.setRecipient(args[1]);    card.setItem(VCard.NAME, "Fredy Bean");    card.setItem(VCard.ORG, "object XP");    card.addItem(VCard.TEL, new String[]{VCard.TYPE_WORK, VCard.TYPE_VOICE}, "0012345678");    card.addItem(VCard.TEL, new String[]{VCard.TYPE_WORK, VCard.TYPE_FAX}, "0023456789");    card.addItem(VCard.TEL, new String[]{VCard.TYPE_HOME, VCard.TYPE_CELL}, "0034567890");    card.addItem(VCard.ADR, new String[]{VCard.TYPE_WORK}, "Marktgasse 11, Winterthur, Switzerland");        // connect, send message and disconnect     try {      service.connect();      service.sendMessage(card);      service.disconnect();    }    finally {      service.destroy();     }  }}

⌨️ 快捷键说明

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