/**
   * Gets an IRandomAccess object that can read from or write to the given file.
   *
   * @see IRandomAccess
   */
  public static IRandomAccess getHandle(String id, boolean writable, boolean allowArchiveHandles)
      throws IOException {
    LOGGER.trace("getHandle(id = {}, writable = {})", id, writable);
    IRandomAccess handle = getMappedFile(id);
    if (handle == null) {
      LOGGER.trace("no handle was mapped for this ID");
      String mapId = getMappedId(id);

      if (id.startsWith("http://")) {
        handle = new URLHandle(mapId);
      } else if (allowArchiveHandles && ZipHandle.isZipFile(id)) {
        handle = new ZipHandle(mapId);
      } else if (allowArchiveHandles && GZipHandle.isGZipFile(id)) {
        handle = new GZipHandle(mapId);
      } else if (allowArchiveHandles && BZip2Handle.isBZip2File(id)) {
        handle = new BZip2Handle(mapId);
      } else {
        handle = new NIOFileHandle(mapId, writable ? "rw" : "r");
      }
    }
    LOGGER.trace("Location.getHandle: {} -> {}", id, handle);
    return handle;
  }
 @Test
 public void testGZipTypeDetection() throws IOException {
   File invalidFile = File.createTempFile("invalid", ".gz");
   invalidFile.deleteOnExit();
   assertEquals(GZipHandle.isGZipFile(invalidFile.getAbsolutePath()), false);
 }