private byte[] getSection(InputStream is, int maxsize, byte bstart, byte bfinish,
                              boolean ifincomplete) {
        byte[] value = new byte[0];

        try {
            boolean started = false;                   // check if we have found the start flag
            boolean finished = false;                  // check if we have found the finish flag
            int read = 0;                              // the number of bytes we read
            int start = 0;                             // the position after the start flag

            // TODO: this only pulls back 8K of data on a read, regardless of buffer size
            //       more nefariously, it caps at a total 8K, through all sections
            int streammax = is.available();
            maxsize = Math.min(maxsize, streammax);

            is.mark(maxsize);
            byte[] buf = new byte[maxsize];
            int totsize = 0;
            int remainder = maxsize - totsize;
            while (remainder > 0) {
                int msgsize = is.read(buf, maxsize - remainder,
                        maxsize);    // read in at least the full data
                if (msgsize == -1) {
                    remainder = msgsize = 0;
                }
                remainder -= msgsize;
                totsize += msgsize;
            }

            // scan through the provided input stream
            for (read = 0; read < totsize; read++) {
                byte b = buf[read];

                if (!started) {
                    started = (b == bstart);
                    start = read + 1;
                    continue;
                }

                if (finished = (b == bfinish)) {
/*
               is.reset();
               long skipped = is.skip((long)read);
               if (skipped != read) {
                  // we are in an unstable state
               }
               is.mark(1);
 */
                    break;
                }

                // load from the stream until we run out of characters, or hit the termination byte
                continue;
            }

            // move the input stream back to where it was initially
            is.reset();

            if (finished) {
                // now, we want to reset the stream to be sitting right on top of the finish marker
                is.skip(read);
                value = new byte[read - start];
                System.arraycopy(buf, start, value, 0, read - start);
            } else {
                if (ifincomplete && started) {
                    // the caller wants anything that was read, and we finished the stream or buffer
                    value = new byte[read - start];
                    System.arraycopy(buf, start, value, 0, read - start);
                }
            }
        } catch (IOException eio) {
            // something invalid occurred, return an empty string
        }

        return (value);
    }
scan the news messsage and store the metadata and data into a map
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-news-module/src/main/java/org/apache/tika/parser/iptc/IptcAnpaParser.java