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

📄 tool.java

📁 一个j2me游戏开发引擎
💻 JAVA
字号:
// 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 

package mmae.util;

import java.util.Calendar;
import java.util.Date;
import javax.microedition.lcdui.Font;

// Referenced classes of package mmae.util:
//            RecordDB

public class Tool
{

    private Tool()
    {
    }

    public static int getStrWidth(String s)
    {
        int i = 0;
        Font font = Font.getFont(0, 1, 8);
        if(s == null)
            i = 0;
        else
            i = font.stringWidth(s);
        return i;
    }

    public static int getStrWidth(String s, int i)
    {
        int j = 0;
        Font font = Font.getFont(0, 1, i);
        if(s == null)
            j = 0;
        else
            j = font.stringWidth(s);
        return j;
    }

    public static int getFontHeight()
    {
        Font font = Font.getFont(0, 1, 8);
        return font.getHeight();
    }

    public static String getField(String s, int i, String s1)
    {
        int j = beginIndexOfField(s, i, s1);
        if(j == -1)
        {
            return s;
        } else
        {
            int k = endIndexOfField(s, i, s1);
            return s.substring(j, k);
        }
    }

    public static int beginIndexOfField(String s, int i, String s1)
    {
        if(i < 1)
            return -1;
        if(i == 1)
            return 0;
        int j = 0;
        int k = 1;
        do
        {
            j = s.indexOf(s1, j);
            k++;
            if(j == -1)
                return -1;
            j += s1.length();
        } while(k != i);
        return j;
    }

    public static int endIndexOfField(String s, int i, String s1)
    {
        if(i < 1)
            return -1;
        int j = 0;
        int k = 0;
        do
        {
            k = s.indexOf(s1, k);
            j++;
            if(k == -1)
                return s.length();
            if(j == i)
                return k;
            k += s1.length();
        } while(true);
    }

    public static int getTrialTimes(String s, int i)
    {
        RecordDB recorddb = new RecordDB();
        recorddb.open(s);
        int j = 0;
        if(recorddb.getNumRecords() == 0)
        {
            j = i - 1;
            recorddb.addRecord(String.valueOf(j));
        } else
        {
            j = Integer.valueOf(recorddb.getRecord(1)).intValue();
            if(--j > 0)
                recorddb.setRecord(1, String.valueOf(j));
        }
        recorddb.close();
        return j;
    }

    public static String getDate(String s)
    {
        Calendar calendar = Calendar.getInstance();
        return calendar.get(1) + s + calendar.get(2) + s + calendar.get(5);
    }

    public static long getTime()
    {
        Date date = new Date();
        return date.getTime();
    }

    public static int getDays(Date date, Date date1)
    {
        return (int)(date1.getTime() - date.getTime()) / 0x5265c00;
    }

    public static String toUTF(byte abyte0[], int i)
    {
        char ac[] = new char[i * 2];
        int j = 0;
        int k = 0;
        while(j < i) 
            try
            {
                char c;
                if((abyte0[j] & 0x80) != 0)
                {
                    if((abyte0[j] & 0x20) != 0)
                    {
                        c = (char)((abyte0[j] & 0xf) << 12);
                        c += (char)(abyte0[j + 1] & 0x3f) << 6;
                        c += abyte0[j + 2] & 0x3f;
                        j += 3;
                    } else
                    {
                        c = (char)((abyte0[j] & 0x1f) << 6);
                        c += abyte0[j + 1] & 0x3f;
                        j += 2;
                    }
                } else
                {
                    c = (char)abyte0[j];
                    j++;
                }
                ac[k++] = c;
            }
            catch(Exception exception) { }
        return new String(ac, 0, k);
    }
}

⌨️ 快捷键说明

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