利用短信猫发送短信的Java代码
前一段需要用短信猫发送短信,写了一段短信猫发送短信的代码:
import javax.comm.*;
import java.util.*;
import java.io.*;
import org.smslib.*;
public class smsModem
{
private static LinkedList<COutgoingMessage> msgList = new LinkedList<COutgoingMessage>();
private static String com="";
private static int baudRate=0;
private static CService srv;
private static boolean isSending=false;
private static void testAndSetCom()
/**
Try to find out which com port is used by modem and the work baudrate.
*/
{
CommPortIdentifier portId;
Enumeration portList;
//int bauds[] = { 9600, 19200, 38400, 115200 };
int bauds[]={38400, 115200};
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements())
{
portId = (CommPortIdentifier) portList.nextElement();
System.out.println("PORTID:"+portId);
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
{
System.out.println("Found port: " + portId.getName());
for (int i = 0; i < bauds.len
相关文档:
java中字符串的编码解码问题
1.将字符串转换成byte数组再恢复:
byte[] getBytes(String charsetName)
String(byte[] bytes, String charsetName)
或getBytes()
String(byte[] bytes)
2.使用String sun.misc.BASE64Encode.encode(byte[] b)
byte[] String sun.misc.BASE64Decode.decodeBuffer(String str)
将字符 ......
Java使用两种方法来处理多线程
第一种是子类化Thread对象。 Thread对象是Java提供的封装线程的对象。如果子类化Thread类,则必须重载这个类中的run方法以提供由这个特殊线程执行的代码。因为Java不支持多重继承,所以如果你的类需要子类化另一个类,那么就不能子类化Thread对象。
第二种是实现由Java提供的Runnable ......
int pagenum=0;
int pagesize = 4;
int nowpage = 1;
String showpage = request.getParameter("page");
String sdept1 = request.getParameter("selectdept");
if(showpage!=null){
nowpage = Convertutil.strtoint(showpage);
}
......
/***************定义接口******************/
package day6;
public interface StudentDao {
public void insert();
public void update();
public void delete();
public void query();
public void FindById();
}
/***************定义接口 借宿***************** ......