Example #1
0
  private void readHeaders(Hashtable headers) throws Exception {
    if (headers != null) {
      m_OutHeaders = new Hashtable();
      for (int i = 0; ; i++) {
        String strField = m_connection.getHeaderFieldKey(i);
        if (strField == null && i > 0) break;

        if (strField != null) {
          String header_field = m_connection.getHeaderField(i);
          m_OutHeaders.put(strField.toLowerCase(), header_field);
        }
      }
    }
  }
Example #2
0
  private boolean isFinishDownload() throws IOException {
    String strContRange = m_connection.getHeaderField("Content-Range");
    if (strContRange != null) {
      int nMinus = strContRange.indexOf('-');
      if (nMinus > 0) {
        int nSep = strContRange.indexOf('/', nMinus);
        if (nSep > 0) {
          String strHigh = strContRange.substring(nMinus + 1, nSep);
          String strTotal = strContRange.substring(nSep + 1);

          if (Integer.parseInt(strHigh) + 1 >= Integer.parseInt(strTotal)) return true;
        }
      }
    }

    return false;
  }