Example #1
0
  /**
   * @param section
   * @param index
   * @return
   * @throws IOException
   */
  final String getStringFromSection(final Section section, final int index) throws IOException {
    if (index > section.getSize()) {
      return "";
    }

    final StringBuffer str = new StringBuffer();
    // Most string symbols will be less than 50 bytes in size
    final byte[] tmp = new byte[50];

    this.efile.seek(section.getFileOffset() + index);
    while (true) {
      int len = this.efile.read(tmp);
      for (int i = 0; i < len; i++) {
        if (tmp[i] == 0) {
          len = 0;
          break;
        }
        str.append((char) tmp[i]);
      }
      if (len <= 0) {
        break;
      }
    }

    return str.toString();
  }