⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jmdefine.java

📁 使用短信猫发送短信的程序源代码
💻 JAVA
字号:
//读取配置文件,初始化
// Source File Name:   JMDefine.java

import java.io.*;

public class JMDefine
{

    public String getLINK_NAME()
    {
        return LINK_NAME;
    }

    public String getDB_DRIVER()
    {
        return DB_DRIVER;
    }

    public String getDB_URL()
    {
        return DB_URL;
    }

    public String getDB_LOGIN()
    {
        return DB_LOGIN;
    }

    public String getDB_PASSWD()
    {
        return DB_PASSWD;
    }

    public String getGATEWAY_IP()
    {
        return GATEWAY_IP;
    }

    public int getGATEWAY_PORT()
    {
        return GATEWAY_PORT;
    }

    public int getTIMEOUT_SEC()
    {
        return TIMEOUT_SEC;
    }

    public int getSLEEP_SEC()
    {
        return SLEEP_SEC;
    }

    public int getMAX_RETRY()
    {
        return MAX_RETRY;
    }

    public int getMAX_SEND_COUNT()
    {
        return MAX_SEND_COUNT;
    }


    public String getCOUNTRY_CODE()
    {
        return COUNTRY_CODE;
    }

    public String getCOUNTRY_PREFIX()
    {
        return COUNTRY_PREFIX;
    }

    public int getPRIORITY_ENABLE()
    {
        return PRIORITY_ENABLE;
    }

    public String getDEFAULT_ENCODE()
    {
        return DEFAULT_ENCODE;
    }

    public void setLINK_NAME(String s)
    {
        LINK_NAME = s;
    }

    public void setDB_DRIVER(String s)
    {
        DB_DRIVER = s;
    }

    public void setDB_URL(String s)
    {
        DB_URL = s;
    }

    public void setDB_LOGIN(String s)
    {
        DB_LOGIN = s;
    }

    public void setDB_PASSWD(String s)
    {
        DB_PASSWD = s;
    }

    public void setGATEWAY_IP(String s)
    {
        GATEWAY_IP = s;
    }

    public void setGATEWAY_PORT(int i)
    {
        GATEWAY_PORT = i;
    }

    public void setTIMEOUT_SEC(int i)
    {
        TIMEOUT_SEC = i;
    }

    public void setSLEEP_SEC(int i)
    {
        SLEEP_SEC = i;
    }

    public void setMAX_RETRY(int i)
    {
        MAX_RETRY = i;
    }

    public void setMAX_SEND_COUNT(int i)
    {
        MAX_SEND_COUNT = i;
    }

    public void setCOUNTRY_CODE(String s)
    {
        COUNTRY_CODE = s;
    }

    public void setCOUNTRY_PREFIX(String s)
    {
        COUNTRY_PREFIX = s;
    }

    public void setPRIORITY_ENABLE(int i)
    {
        PRIORITY_ENABLE = i;
    }

    public void setDEFAULT_ENCODE(String s)
    {
        DEFAULT_ENCODE = s;
    }

    public int saveConfig()
    {
        String s;
        if(System.getProperty("line.separator").equals("\r\n"))
            s = "\r\n";
        else
            s = "\n";
        String s1 = "# JiteMessage Configuration" + s + "# version " + SMSSender.JM_VERSION + s + s + "LINK_NAME         = " + LINK_NAME + s +  "DEFAULT_ENCODE    = " + DEFAULT_ENCODE + s + "DB_DRIVER         = " + DB_DRIVER + s + "DB_URL            = " + DB_URL + s + "DB_LOGIN          = " + DB_LOGIN + s + "DB_PASSWD         = " + DB_PASSWD + s + "GATEWAY_IP        = " + GATEWAY_IP + s + "GATEWAY_PORT      = " + GATEWAY_PORT + s + "TIMEOUT_SEC       = " + TIMEOUT_SEC + s + "SLEEP_SEC         = " + SLEEP_SEC + s + "MAX_RETRY         = " + MAX_RETRY + s + "MAX_SEND_COUNT    = " + MAX_SEND_COUNT + s +  "COUNTRY_CODE      = " + COUNTRY_CODE + s + "COUNTRY_PREFIX    = " + COUNTRY_PREFIX + s + "PRIORITY_ENABLE   = " + PRIORITY_ENABLE + s ;
        try
        {
            FileOutputStream fileoutputstream = new FileOutputStream("./jetmessage.conf");
            fileoutputstream.write(s1.getBytes());
            fileoutputstream.close();
        }
        catch(Exception exception)
        {
            return 1;
        }
        return 0;
    }

    public JMDefine(boolean flag)
    {
        LINK_NAME = "link1";
        DB_DRIVER = "";
        DB_URL = "";
        DB_LOGIN = "";
        DB_PASSWD = "";
        GATEWAY_IP = "192.168.42.10";
        GATEWAY_PORT = 4660;
        TIMEOUT_SEC = 120;
        SLEEP_SEC = 30;
        MAX_RETRY = 3;
        MAX_SEND_COUNT = 50;
        COUNTRY_CODE = "86";
        COUNTRY_PREFIX = "+";
        PRIORITY_ENABLE = 1;
        DEFAULT_ENCODE = "GB2312";
        byte abyte0[] = new byte[1024];
        try
        {
            FileInputStream fileinputstream = new FileInputStream("./jitemessage.conf");
            int i;
            String s;
            String s1;
            for(s1 = ""; (i = fileinputstream.read(abyte0, 0, 1024)) != -1; s1 = s1 + s)
                s = new String(abyte0, 0, i);

            s1 = s1.replace('\t', ' ');
            s1 = s1.replace('\r', '\n');
            int j = 0;

            while(j < s1.length() - 1) 
            {
                int k = s1.indexOf('\n', j);
                String s2;
                if(k == -1)
                {
                    s2 = s1.substring(j);
                    j = s1.length();
                } else
                {
                    s2 = s1.substring(j, k);
                    j = k + 1;
                }
                s2 = s2.trim();
                if((k = s2.indexOf('=')) != -1 && !s2.startsWith("#") && s2.length() != 0)
                {
                    String s3 = s2.substring(0, k).trim();
                    String s4 = s2.substring(k + 1).trim();
                    if(s3.equals("LINK_NAME"))
                        LINK_NAME = s4;
                    if(s3.equals("DB_DRIVER"))
                        DB_DRIVER = s4;
                    if(s3.equals("DB_URL"))
                        DB_URL = s4;
                    if(s3.equals("DB_LOGIN"))
                        DB_LOGIN = s4;
                    if(s3.equals("DB_PASSWD"))
                        DB_PASSWD = s4;
                    if(s3.equals("GATEWAY_IP"))
                        GATEWAY_IP = s4;
                    if(s3.equals("GATEWAY_PORT"))
                        GATEWAY_PORT = Integer.decode(s4).intValue();
                    if(s3.equals("TIMEOUT_SEC"))
                        TIMEOUT_SEC = Integer.decode(s4).intValue();
                    if(s3.equals("SLEEP_SEC"))
                        SLEEP_SEC = Integer.decode(s4).intValue();
                    if(s3.equals("MAX_RETRY"))
                        MAX_RETRY = Integer.decode(s4).intValue();
                    if(s3.equals("MAX_SEND_COUNT"))
                        MAX_SEND_COUNT = Integer.decode(s4).intValue();
                    if(s3.equals("COUNTRY_CODE"))
                        COUNTRY_CODE = s4;
                    if(s3.equals("COUNTRY_PREFIX"))
                        COUNTRY_PREFIX = s4;
                    if(s3.equals("PRIORITY_ENABLE"))
                        PRIORITY_ENABLE = Integer.decode(s4).intValue();
                    if(s3.equals("DEFAULT_ENCODE"))
                        DEFAULT_ENCODE = s4;
                }
            }
        }
        catch(Exception exception)
        {
            System.out.println("Error read configuration.");
            System.exit(1);
        }
    }

    private String LINK_NAME;
    private String DB_DRIVER;
    private String DB_URL;
    private String DB_LOGIN;
    private String DB_PASSWD;
    private String GATEWAY_IP;
    private int GATEWAY_PORT;
    private int TIMEOUT_SEC;
    private int SLEEP_SEC;
    private int MAX_RETRY;
    private int MAX_SEND_COUNT;
    private String COUNTRY_CODE;
    private String COUNTRY_PREFIX;
    private int PRIORITY_ENABLE;
    private String DEFAULT_ENCODE;
}

⌨️ 快捷键说明

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