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

📄 savegame.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 

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

class SaveGame
{

    static RecordStore myGame;
    static boolean gameHaveBeenInit = false;
    static String gameData;

    private SaveGame()
    {
    }

    private static void initialize()
    {
        ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
        DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
        try
        {
            byte abyte0[];
            try
            {
                dataoutputstream.writeUTF("A@0/B*0~C^0(D)0!E#0%F&0");
                abyte0 = bytearrayoutputstream.toByteArray();
                dataoutputstream.close();
            }
            catch(IOException ioexception)
            {
                System.out.println(ioexception);
                throw new RecordStoreException();
            }
            myGame.addRecord(abyte0, 0, abyte0.length);
        }
        catch(RecordStoreException recordstoreexception)
        {
            close();
            System.out.println(recordstoreexception);
        }
    }

    static void open()
    {
        try{
        myGame = RecordStore.openRecordStore("topscore", true);
        if(gameHaveBeenInit)
            return;
        try
        {
            if(myGame.getNumRecords() == 0)
            {
                initialize();
            } else
            {
                byte abyte0[] = myGame.getRecord(1);
                if(abyte0 != null)
                    try
                    {
                        ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(abyte0);
                        DataInputStream datainputstream = new DataInputStream(bytearrayinputstream);
                        gameData = datainputstream.readUTF();
                        datainputstream.close();
                        if(gameData.equals(""))
                        {
                            gameData = "A@0/B*0~C^0(D)0!E#0%F&0";
                            saveGame(gameData);
                        }
                    }
                    catch(IOException ioexception) { }
            }
            gameHaveBeenInit = true;
        }
        catch(RecordStoreException recordstoreexception)
        {
            System.out.println(recordstoreexception);
        }
        }catch(Exception e){}
        return;
    }

    static void close()
    {
        if(myGame != null)
        {
            try
            {
                myGame.closeRecordStore();
            }
            catch(RecordStoreException recordstoreexception) { }
            myGame = null;
        }
    }

    static void saveGame(String s)
    {
        try
        {
            byte abyte0[];
            try
            {
                ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
                DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
                dataoutputstream.writeUTF(s);
                abyte0 = bytearrayoutputstream.toByteArray();
                dataoutputstream.close();
            }
            catch(IOException ioexception)
            {
                throw new RecordStoreException();
            }
            if(myGame == null)
            {
                open();
                myGame.setRecord(1, abyte0, 0, abyte0.length);
                close();
            } else
            {
                myGame.setRecord(1, abyte0, 0, abyte0.length);
            }
        }
        catch(RecordStoreException recordstoreexception) { }
        gameData = s;
    }

    static String getGameData()
    {
        if(!gameHaveBeenInit)
        {
            open();
            close();
        }
        return gameData;
    }

}

⌨️ 快捷键说明

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