或者相关资料也可以,http://www.gjwtech.com/serialcomm.htm 这个网站的就不用给我了。

解决方案 »

  1.   

    先从sun下载javax.comm包
    以下是一个发送at命令到com口的程序:
    import java.io.*;
    import java.util.Enumeration;
    import javax.comm.*;public class SimpleWrite
    {    static Enumeration portList;
        static CommPortIdentifier portId;
        static SerialPort serialPort;
        static OutputStream outputStream;
        static InputStream inputStream;
        static char c34;
        static char c26 = '\032';
        static String mString1 = "AT+CSCA=+8613800200500" + "\n";
        static String mString2="AT+CMGF=1" + "\n";
        static String mString3="AT+CMGS=\"+86136.....\"" + "hello" + '\032'+"\n";
    //static String messageString1 = "AT+CMGS=\"136.....\"\n\r";
    //static String messageString2 = "Got this Message? \u001A\r";
        public SimpleWrite()
        {
        }    public static void main(String args[])
            throws Exception
        {

    CommPortIdentifier commportidentifier = CommPortIdentifier.getPortIdentifier("COM2");
            serialPort = (SerialPort)commportidentifier.open("sms app", 3000);
            try
            {
                outputStream = serialPort.getOutputStream();
                inputStream = serialPort.getInputStream();
            }
            catch(IOException ioexception)
            {
            }
            try
            {
               serialPort.setSerialPortParams(9600,
               SerialPort.DATABITS_8,
               SerialPort.STOPBITS_1,
               SerialPort.PARITY_NONE);        }
            catch(UnsupportedCommOperationException unsupportedcommoperationexception)
            {
               
            }        try
            {
                outputStream.write(mString1.getBytes());
                outputStream.write(mString2.getBytes());
                outputStream.write(mString3.getBytes());
       outputStream.flush();
       outputStream.close();        }
            catch(IOException ioexception1)
            {
            }
        }}
      

  2.   

    javax.comm这个扩展类怎么下的?我好象找不到。能给个地址吗?
      

  3.   

    http://java.sun.com/products/javacomm/