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

📄 pkgtools.java

📁 手机中用的MobileQQ源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 

import java.io.*;
import java.util.Vector;
import javax.microedition.lcdui.*;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreNotFoundException;

public class PkgTools
{

    private static final String DBName = "QQDB";
    private static final int C_Record_Num = 13;
    private static final int C_BlackListStart = 3;
    private static String DBStrings[] = new String[13];

    public PkgTools()
    {
    }

    public static String To2Str(int i)
    {
        if(i < 10)
            return "0" + i;
        else
            return "" + i;
    }

    public static Image createImage(String s)
    {
        Image image = null;
        try
        {
            image = Image.createImage(s);
        }
        catch(IOException ioexception) { }
        return image;
    }

    public static void EmptyForm(Form form)
    {
        for(int i = form.size() - 1; i >= 0; i--)
            form.delete(i);

    }

    public static void EmptyList(List list)
    {
        for(int i = list.size() - 1; i >= 0; i--)
            list.delete(i);

    }

    public static String Encodecgi(String s)
    {//编码函数:将字符串中的' '、'&'、','、'\r'、'\t'、'\n'、'%'、'='
     //这些字符转换成形如%XX的形式,其中XX为上述字符的ASCII码的十六进制形式;
        StringBuffer stringbuffer = new StringBuffer();
        if(s == null)
            return "";
        char ac[] = s.toCharArray();
        int i = ac.length;
        if(i == 0)
            return "";
        for(int j = 0; j < i; j++)
            if(ac[j] == ' ' || ac[j] == '&' || ac[j] == ',' || ac[j] == '\r' || ac[j] == '\t' || ac[j] == '\n' || ac[j] == '%' || ac[j] == '=')
            {
                String s1 = Integer.toHexString(ac[j]);
                if(s1.length() == 1)
                    stringbuffer.append("%0" + s1);
                else
                    stringbuffer.append("%" + s1);
            } else
            {
                stringbuffer.append(ac[j]);
            }

        return stringbuffer.toString();
    }

    public static String Decodecgi(String s)
    {//解码函数,将含有形如%XX的十六进制数据的字符串中的%XX转换成一个字符;
     //返回转换后的字符串;
        StringBuffer stringbuffer = new StringBuffer();
        if(s == null)
            return "";
        char ac[] = s.toCharArray();
        int j = ac.length;
        if(j == 0)
            return "";
        for(int i = 0; i < j;)
            if(ac[i] == '%')
            {
                String s1 = String.valueOf(ac, i + 1, 2);
                char c;
                try
                {
                    c = (char)Integer.parseInt(s1, 16);
                }
                catch(Exception exception)
                {
                    c = ' ';
                }
                stringbuffer.append(c);
                i += 3;
            } else
            {
                stringbuffer.append(ac[i]);
                i++;
            }

        return stringbuffer.toString();
    }

    public static String GetParaVal(String s, String s1)
    {
        String s2 = null;
        int i = 0;
        int j = 0;
        int k = 0;
        int l = 0;
        if(s == null || s1 == null)
            return "";
        s = s + "=";
        k = s.length();
        l = s1.length();
        if(l == 0)
            return "";
        if(k == 0 || k > 9)
            return "";
        i = s1.indexOf(s);
        if(i == -1)
            return "";
        j = s1.indexOf(38, i);
        if(j == -1)
            s2 = s1.substring(i + k);
        else
            s2 = s1.substring(i + k, j);
        return s2;
    }

    public static int GetMultiPara(String as[], String s)
    {
        int i = 0;
        String s1 = null;
        int j = 0;
        int k = 0;
        boolean flag = false;
        if(as == null || s == null)
            return -1;
        j = s.length();
        if(j >= 2560)
            return -1;
        i = s.indexOf(44);
        if(i == -1)
        {
            as[0] = s;
            return 1;
        }
        as[0] = s.substring(0, i);
        if(++k == as.length)
            return k;
        for(s1 = s.substring(i + 1); (i = s1.indexOf(44)) != -1; s1 = s1.substring(i + 1))
        {
            as[k] = s1.substring(0, i);
            if(++k == as.length)
                return k;
        }

        as[k] = s1;
        return ++k;
    }

    public static byte[] Unicode2Byte(String s)
    {
        int i = s.length();
        byte abyte0[] = new byte[i << 1];
        int j = 0;
        for(int k = 0; k < i; k++)
        {
            char c = s.charAt(k);
            abyte0[j++] = (byte)(c & 0xff);
            abyte0[j++] = (byte)(c >> 8);
        }

        return abyte0;
    }

    public static byte[] convertUnicode2UTF8Byte(String s)
    {
        int i = s.length();
        byte abyte0[] = new byte[i << 2];
        int j = 0;
        for(int k = 0; k < i; k++)
        {
            char c = s.charAt(k);
            if(c < '\200')
                abyte0[j++] = (byte)c;
            else
            if(c < '\u0800')
            {
                abyte0[j++] = (byte)(c >> 6 & 0x1f | 0xc0);
                abyte0[j++] = (byte)(c & 0x3f | 0x80);
            } else
            if(c < '\0')
            {
                abyte0[j++] = (byte)(c >> 12 & 0xf | 0xe0);
                abyte0[j++] = (byte)(c >> 6 & 0x3f | 0x80);
                abyte0[j++] = (byte)(c & 0x3f | 0x80);
            } else
            if(c < '\0')
            {
                abyte0[j++] = (byte)(c >> 18 & 0x7 | 0xf0);
                abyte0[j++] = (byte)(c >> 12 & 0x3f | 0x80);
                abyte0[j++] = (byte)(c >> 6 & 0x3f | 0x80);
                abyte0[j++] = (byte)(c & 0x3f | 0x80);
            }
        }

        byte abyte1[] = new byte[j];
        for(int l = 0; l < j; l++)
            abyte1[l] = abyte0[l];

        return abyte1;
    }

    public static void saveDB()
    {
label0:
        {
            RecordStore recordstore = null;
            ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
            DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
            Object obj = null;
            try
            {
                recordstore = RecordStore.openRecordStore("QQDB", true);
                int i = recordstore.getNumRecords();
                for(int j = 0; j < 13; j++)
                    dataoutputstream.writeUTF(DBStrings[j]);

                byte abyte0[] = bytearrayoutputstream.toByteArray();
                if(i == 0)
                    recordstore.addRecord(abyte0, 0, abyte0.length);
                else
                    recordstore.setRecord(1, abyte0, 0, abyte0.length);
            }
            catch(Exception exception2)
            {
                try
                {
                    dataoutputstream.close();
                }
                catch(Exception exception3) { }
                if(recordstore != null)
                    try
                    {
                        recordstore.closeRecordStore();
                    }
                    catch(Exception exception4) { }
                break label0;
            }
            finally
            {
                try
                {
                    dataoutputstream.close();
                }
                catch(Exception exception6) { }
                if(recordstore != null)
                    try
                    {
                        recordstore.closeRecordStore();
                    }
                    catch(Exception exception7) { }
                throw exception5;
            }
            try
            {
                dataoutputstream.close();
            }
            catch(Exception exception) { }
            if(recordstore != null)
                try
                {
                    recordstore.closeRecordStore();
                }
                catch(Exception exception1) { }
            break label0;
        }
    }

    public static void loadDB()
    {
label0:
        {
            RecordStore recordstore = null;
            Object obj = null;
            DataInputStream datainputstream = null;
            Object obj1 = null;
            try
            {
                recordstore = RecordStore.openRecordStore("QQDB", true);
                int k = recordstore.getNumRecords();
                if(k == 0)
                {
                    DBStrings[0] = "0";
                    DBStrings[1] = "";

⌨️ 快捷键说明

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