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

📄 cload.java

📁 网上收集的
💻 JAVA
字号:
package chiidanceapp;import java.io.InputStream;import java.io.FileInputStream;import java.io.ObjectInputStream;import java.util.ResourceBundle;//读取数据类public class CLoad {  static ResourceBundle res = ResourceBundle.getBundle("chiidanceapp.Res1");  /////////////////////////////////////////////////////////////////////  FileInputStream InputFile,TimeFile,ScoreFile,ActRushFile,RefleshFile;  ObjectInputStream ObjIn;  private int Score;  private int ActRushed;  private int RefleshSpeed;  configdata data;  CTime Time;  ////////////////////////////////////////////////////////////  public CLoad() {  }  //读取已有的游戏时间  public synchronized Object loadTime()  {    try    {     TimeFile = new FileInputStream( "config.dat" );     ObjIn = new ObjectInputStream( InputFile );     data = ( configdata )ObjIn.readObject();//从记录文件中读取对象然后传给另外一个对象     //关闭输入流     TimeFile.close();     ObjIn.close();     //System.out.println( "成功载入时间" );     }catch( Exception ex )     {       System.out.println( "读取游戏失败!" );     }     return this.Time;  }  //读取游戏设置  public synchronized Object loadGame()  {    try    {     InputFile = new FileInputStream( "config.dat" );     ObjIn = new ObjectInputStream( InputFile );     data = ( configdata )ObjIn.readObject();//从记录文件中读取对象然后传给另外一个对象     //关闭输入流     InputFile.close();     ObjIn.close();     //System.out.println( "成功载入设置" );     }catch( Exception ex )     {       System.out.println( "读取游戏失败!" );     }     return this.data;  }  //读取是否通关的资料  public synchronized int loadActRushed()  {    try    {      ActRushFile = new FileInputStream( "data/d2.sav" );      ObjIn = new ObjectInputStream( ActRushFile );//这里可能有个错误,重复      this.ActRushed = ( int )ObjIn.readInt();//从记录文件中读取对象然后传给另外一个对象      ActRushFile.close();      ObjIn.close();      //System.out.println( "成功载入游戏状态" );      }catch( Exception ex )      {      System.out.println( "载入游戏状态失败!" );      }    return this.ActRushed;  }  //读取分数资料  public synchronized int loadScore()  {    try    {      ScoreFile = new FileInputStream( "data/d3.sav" );      ObjIn = new ObjectInputStream( ScoreFile );      this.Score = ( int )ObjIn.readInt();      ScoreFile.close();      ObjIn.close();      //System.out.println( "成功载入游戏分数"+Score );      }catch( Exception ex )      {        System.out.println( "载入游戏分数失败!" );      }    return this.Score;  }  public synchronized int loadRefleshSpeed()  {    try    {      RefleshFile = new FileInputStream( "data/d4.sav" );      ObjIn = new ObjectInputStream( RefleshFile );      this.RefleshSpeed = ( int )ObjIn.readInt();      RefleshFile.close();      ObjIn.close();      //System.out.println( "成功载入刷屏速度"+RefleshSpeed );      }catch( Exception ex )      {        System.out.println( "载入刷屏速度失败!" );      }    return this.RefleshSpeed;  }  ////////////////////////////////////////////////////////////}

⌨️ 快捷键说明

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