record.java

来自「充气球的j2me代码,可以自由的部署在eclipse,netbeas里面.希望大」· Java 代码 · 共 102 行

JAVA
102
字号
// 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 
// Source File Name:   Record.java

import java.io.*;
import javax.microedition.rms.RecordStore;

public class Record
{

    private static RecordStore rs;

    public Record()
    {
    }

    public static void open()
    {
        try
        {
            rs = RecordStore.openRecordStore(Resources.QRS, true);
        }
        catch(Exception e) { }
    }

    public static void close()
    {
        try
        {
            rs.closeRecordStore();
        }
        catch(Exception e) { }
    }

    public static void delete()
    {
        if(RecordStore.listRecordStores() != null)
            try
            {
                RecordStore.deleteRecordStore(Resources.QRS);
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
    }

    public static void save()
    {
        try
        {
            ByteArrayOutputStream arrBytes = new ByteArrayOutputStream();
            DataOutputStream Data = new DataOutputStream(arrBytes);
            for(int i = 0; i < 5; i++)
            {
                Data.writeUTF(Resources.highscore[i]);
                Data.flush();
                byte b[] = arrBytes.toByteArray();
                int num = rs.addRecord(b, 0, b.length);
                arrBytes.reset();
            }

            arrBytes.close();
            Data.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void load()
    {
        try
        {
            byte b[] = new byte[50];
            ByteArrayInputStream arrBytes = new ByteArrayInputStream(b);
            DataInputStream Data = new DataInputStream(arrBytes);
            for(int i = 1; i <= rs.getNumRecords(); i++)
            {
                rs.getRecord(i, b, 0);
                String s = Data.readUTF();
                Resources.highscore[i - 1] = s;
                arrBytes.reset();
            }

            arrBytes.close();
            Data.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public static String getLevel(int x)
    {
        return String.valueOf(x);
    }
}

⌨️ 快捷键说明

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