最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

java調(diào)用短信貓發(fā)短信示例

 更新時(shí)間:2014年04月30日 09:43:04   作者:  
這篇文章主要介紹了java調(diào)用短信貓發(fā)短信示例,需要的朋友可以參考下

具體的操作步驟如下:
1、把smslib-3.3.0b2.jar、comm.jar與log4j-1.2.11.jar,放入到工程的lib中;
2、把javax.comm.properties放到%JAVA_HOME%/jre/lib下;
3、把win32com.dll放到%JAVA_HOME%/jre/bin下;
4  把comm.jar放到%JAVA_HOME%/jre/ext下
注意:路徑放錯(cuò),調(diào)用起來(lái)就會(huì)報(bào)錯(cuò);JDK的版本,用的版本是jdk-1_5_0_04。

復(fù)制代碼 代碼如下:

ackage com.alonely.notecat;
import org.smslib.IOutboundMessageNotification;
import org.smslib.Outbou、ndMessage;
import org.smslib.Service;
import org.smslib.Message.MessageEncodings;
import org.smslib.modem.SerialModemGateway;

public class SendMessage {
 public class OutboundNotification implements IOutboundMessageNotification {
  public void process(String gatewayId, OutboundMessage msg) {
   System.out.println("Outbound handler called from Gateway: "
     + gatewayId);
   System.out.println(msg);
  }
 }
 @SuppressWarnings("deprecation")
 public void sendSMS(String mobilePhones, String content) {
  Service srv;
  OutboundMessage msg;
  OutboundNotification outboundNotification = new OutboundNotification();
  srv = new Service();
  SerialModemGateway gateway = new SerialModemGateway("modem.com3",
    "COM3", 9600, "wavecom", ""); //設(shè)置端口與波特率
  gateway.setInbound(true);
  gateway.setOutbound(true);
  gateway.setSimPin("0000");
  gateway.setOutboundNotification(outboundNotification);
  srv.addGateway(gateway);
  System.out.println("初始化成功,準(zhǔn)備開(kāi)啟服務(wù)");
  try {
   srv.startService();
   System.out.println("服務(wù)啟動(dòng)成功");
   String[] phones = mobilePhones.split(",");
   for (int i = 0; i < phones.length; i++) {
    msg = new OutboundMessage(phones[i], content);
    msg.setEncoding(MessageEncodings.ENCUCS2); // 中文
    srv.sendMessage(msg);
   }
   srv.stopService();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }
 public static void main(String[] args) {
  SendMessage sendMessage = new SendMessage();
  sendMessage.sendSMS("您要發(fā)送的手機(jī)號(hào)", "您要發(fā)送的內(nèi)容!");
 }
}

相關(guān)文章

最新評(píng)論

丰顺县| 合阳县| 深圳市| 井冈山市| 北碚区| 平塘县| 论坛| 梓潼县| 奈曼旗| 延吉市| 南宁市| 深州市| 保康县| 夏河县| 楚雄市| 平远县| 江达县| 咸阳市| 乌拉特中旗| 宁陕县| 金乡县| 吉安县| 平利县| 武川县| 老河口市| 武川县| 米林县| 铅山县| 本溪| 镇赉县| 福建省| 扎鲁特旗| 丹寨县| 石景山区| 耒阳市| 衡东县| 正阳县| 潮州市| 双桥区| 东明县| 万安县|