各位您好,我现在正在做一个JAVA短信收发程序,采用C/S模式,所以我就要用一个类实现这三个方法,就是把下面的类改成一个方法,但是参数是数组形式的,我在业务逻辑里面要调用这些方法时候就很不好用,各位有好的建议吗?谢谢了.我邮箱是
[email protected]
import cn.com.chundi.sendsms.*;
import java.util.*;public class Readmsg{
  public static void main(String args[]){
    String index = null;
    String begin = null;
    String end = null;
    Sms sms1 = new Sms();
    if ( args.length > 1 ) {
      begin = args[0];
      end = args[1];
      System.out.println("正在读取SIM中第" + begin + "条至第" + end + "条短信...............");
      ArrayList listmsg = sms1.readmsg(begin,end);
      if (listmsg == null){
         System.out.println(" 读取操作失败! ");
      }
      else{
        int total = listmsg.size();         
        for (int i=0;i<total ; i++){
        Read msg = (Read) listmsg.get(i);
        if ((msg != null) && (msg.isempty()==false)){
        System.out.println("SIM中第" + msg.getno() + "条短信如下:");
        System.out.println("来自: " + msg.getoa());
        System.out.println("时间: " + msg.gettimestamp());
         System.out.println("内容: " + msg.getmsg());
       }
       else{
         System.out.println("SIM中第" + msg.getno() + "位置无短信");
       }   
     }
   }
 }
 else{
   if ( args.length >0){
     index = args[0];
     System.out.println("正在读取SIM中第" + index + "条短信.....................................");
     Read msg = sms1.readmsg(index);
     if ((msg != null) && (msg.isempty()==false)){
       System.out.println("来自: " + msg.getoa());
       System.out.println("时间: " + msg.gettimestamp());
       System.out.println("内容: " + msg.getmsg());
     }
     else{
       System.out.println("SIM中第" + index + "位置无短信");
     }                   
   }
 }       
}
}发:
static boolean sendmsg(String msg,String phone)
msg 您要发送的短信内容
phone 接收者号码
例:
import cn.com.chundi.sendsms.*;public class Sendmsg{
public static void main(String args[]){
String toPhone  = "13331012788";
Sms sms1 = new Sms();
if (args.length>=1)
{
toPhone = args[0];
}
boolean sendsucc = sms1.sendmsg("你好,测试!",toPhone);
if(sendsucc){
System.out.println("send successful..............");
}else{
System.out.println("send failure........");
}
}
}删除:
import cn.com.chundi.sendsms.*;
import java.util.*;public class Deletemsg{
public static void main(String args[]){
String index = null;
String begin = null;
String end = null;
Sms sms1 = new Sms();
if ( args.length > 1 ) {
begin = args[0];
end = args[1];
System.out.println("正在删除SIM中第" + begin + "条至第" + end + "条短信.....................");
ArrayList listmsg = sms1.deletemsg(begin,end);
if (listmsg == null){
System.out.println(" 删除操作失败! ");
}
else{
int total = listmsg.size();         
for (int i=0;i<total ; i++){
Delete msg = (Delete) listmsg.get(i);
if ((msg != null) && (msg.isdelete()==true)){
System.out.println("SIM中第" + msg.getno() + "条短信成功删除");
}
else{
System.out.println("SIM中第" + msg.getno() + "条短信删除失败");
}   
}
}
}
else{
if ( args.length >0){
index = args[0];
System.out.println("正在删除SIM中第" + index + "条短信........................");
Delete del = sms1.deletemsg(index);
if ((del != null) && (del.isdelete()==true)){
System.out.println("SIM中第" + index + "条短信成功删除");
}
else{
System.out.println("SIM中第" + index + "条短信删除失败");
}
}
}
}
}各位达人能不能帮小弟看下.