private long findFourccAndRead(int fourcc, boolean isList, long endPosition,
            boolean throwNotFoundException) throws Exception, IOException {
        long nextPos;
        boolean contentOk = false;
        do {
            int type = readType(endPosition);
            if (type == 0) {            //reached endPosition without finding
                if (throwNotFoundException)
                    throw new Exception("Required item '"+fourccString(fourcc)+"' not found");
                else
                    return -1;
            }
            long size = readInt() & SIZE_MASK;
            nextPos = raFile.getFilePointer() + size;
            if (isList && type == FOURCC_LIST)
                type = readInt();
            if (verbose)
                IJ.log("Searching for '"+fourccString(fourcc)+"', found "+fourccString(type)+
                        "' "+posSizeString(nextPos-size, size));
            if (type==fourcc) {
                contentOk = readContents(fourcc, nextPos);
            } else if (verbose)
                IJ.log("Discarded '"+fourccString(type)+"': Contents does not fit");
            raFile.seek(nextPos);
            if (contentOk)
                return nextPos;         //found and read, breaks the loop
        } while (!contentOk);
        return nextPos;
    }