Esempio n. 1
0
  private void loadFromIndexOfIndexFile(final FileAccessBase file) throws IOException {
    if (file.isFile() && file.canRead()) {

      byte[] buf = new byte[bufLen];
      int pos = 0;
      int ret = 0;
      int contentLength = 0;
      // read the bocket size,it's 4 byte
      ret = file.read(buf, pos, 4);
      bucketSize = getIntFromByte(pos, buf);
      do {
        ret = file.read(buf, pos, buf.length - pos);
        if (ret == -1) {
          break;
        }
        contentLength = pos + ret;
        pos = parseIndexOfIndexBuf(buf, contentLength);
      } while (true);
      file.close();
      buf = null;
      // System.gc();
    }
  }
Esempio n. 2
0
  protected boolean loadInfo() {
    String s = getLocation();
    s = s.substring(preifx.length());
    String[] tmp = com.teesoft.jfile.resource.resourceFileAccess.split(s, '/');
    dict = tmp[0];
    file = tmp[1];
    sparseSize = (int) SIZE;
    try {
      String url = OnlineInfo.dictsizeUrl + dict + "/" + file;
      FileAccessBase con = FileFactory.openFileAccess(url, false);
      byte[] buf = new byte[32];
      int len = con.read(buf);

      filesize = Long.parseLong(new String(buf, 0, len)); //
      // con.fileSize();
      setConnection(con);
    } catch (Exception ex) {
      return false;
    }
    return true;
  }
Esempio n. 3
0
  private void loadFromIndexFile(FileAccessBase file) throws IOException {
    if (file != null && file.isFile() && file.canRead()) {

      byte[] buf = new byte[bufLen];
      int pos = 0;
      int ret = 0;
      int contentLength = 0;
      do {
        ret = file.read(buf, pos, buf.length - pos);
        if (ret <= 0) {
          break;
        }
        contentLength = pos + ret;
        pos = parseBuf(buf, contentLength);
        // System.out.println( Runtime.getRuntime().freeMemory() + " of " +
        // Runtime.getRuntime().totalMemory() );
      } while (true);
      file.close();
      buf = null;
      // System.gc();
    }
  }