private String detect(Detector detector, String bz2Name) throws IOException  {
        try (InputStream is = new BufferedInputStream(
                this.getClass().getResourceAsStream(
                        "/test-documents/bz2/" + bz2Name))) {
            return detector.detect(is, new Metadata()).toString();
        }
    }
Prevent reading the entire len of bytes if requesting more
than 10 bytes.
tika-core/src/test/java/org/apache/tika/detect/MagicDetectorTest.java