Package util.io

Examples of util.io.BufferedRandomAccessFile


      ClassNotFoundException {
    checkValid();
//    System.out.println(mDayProgram.getDate().toString() + " " + mDayProgram.getChannel().getName());
    mTimeLimitationlData = !update;

    BufferedRandomAccessFile dataFile = null;
    try {
      dataFile = new BufferedRandomAccessFile(mFile, "rw");

      int version = dataFile.readInt();

      if (version < 2) {
        dataFile.close();
        updateToVersion2();
        dataFile = new BufferedRandomAccessFile(mFile, "rw");
        int ver2 = dataFile.readInt();

        if (ver2 < 2) {
          mValid = false;
          checkValid();
        }
      }

      mDayProgram.setLastProgramHadEndOnUpdate(dataFile.readBoolean());

      Date date = Date.readData(dataFile);
      Channel channel = Channel.readData(dataFile, false);

      boolean timeLimited = channel.isTimeLimited();
      int startTimeLimit = channel.getStartTimeLimit();
      int endTimeLimit = channel.getEndTimeLimit();

      int size = dataFile.readInt();
      mDayProgram.removeAllPrograms();
      for (int i = 0; i < size; i++) {
        Program prog = loadProgram(dataFile, date, channel);

        if (prog != null) {
          int time = prog.getHours() * 60 + prog.getMinutes();
          if (timeLimited && !update) {
            if ((startTimeLimit < endTimeLimit && time >= startTimeLimit && time < endTimeLimit)
                || (endTimeLimit < startTimeLimit && (time < endTimeLimit || time >= startTimeLimit))) {
              mDayProgram.addProgram(prog);
            }
          }
          else {
            mDayProgram.addProgram(prog);
          }
        }else {
          break;
        }
      }

      dataFile.close();
    } finally {
      if (dataFile != null) {
        try {
          dataFile.close();
        } catch (IOException exc) {}
      }
    }
  }
View Full Code Here

TOP

Related Classes of util.io.BufferedRandomAccessFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.