public void parse(InputStream stream, ContentHandler handler, Metadata metadata,
                      ParseContext context) throws IOException, SAXException, TikaException {
        UnsynchronizedByteArrayOutputStream os = UnsynchronizedByteArrayOutputStream.builder().get();
        IOUtils.copy(stream, os);

        String name = metadata.get(TikaCoreProperties.RESOURCE_NAME_KEY);
        if (name == null) {
            name = "";
        }
        try {
            NetcdfFile ncFile = NetcdfFile.openInMemory(name, os.toByteArray());
            unravelStringMet(ncFile, null, metadata);
        } catch (IOException e) {
            throw new TikaException("HDF parse error", e);
        }

        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
        xhtml.startDocument();
        xhtml.endDocument();
    }
@Test
    public void testHDF4() throws Exception {
        if (System.getProperty("java.version").startsWith("1.5")) {
            return;
        }
        Parser parser = new HDFParser();
        ContentHandler handler = new BodyContentHandler();
        Metadata metadata = new Metadata();

        /*
         * this is a publicly available HDF4 file from the HD4 examples:
         *
         * http://www.hdfgroup.org/training/hdf4_chunking/Chunkit/bin/input54kmdata.hdf
         */
        try (InputStream stream = HDFParser.class.getResourceAsStream("/test-documents/test.hdf")) {
            parser.parse(stream, handler, metadata, new ParseContext());
        }

        assertNotNull(metadata);
        assertEquals("Direct read of HDF4 file through CDM library", metadata.get("_History"));
        assertEquals("Ascending", metadata.get("Pass"));
        assertEquals("Hierarchical Data Format, version 4", metadata.get("File-Type-Description"));
    }