How to read hdf5 format file?

hello, i’m a user of Beam and i don’t have the time to turn to SNAP due to a previous project based on Beam. i want to read hdf5 file in my java program recently , so i want to know if SNAP is able to read hdf5 file and how to read?
thanks in advance!
supplement: i install the SNPA and then use it to open a hdf5 file, but an error occurs(no product reader).

SNAP can read more or less the same HDF5 files as BEAM.
But not all HDF5 specialities are supported.

Reading such a file is done in the same way as in BEAM.

Product myProduct = ProductIO.readProduct(<FILE_PATH>);

Update: As you have already tried and SNAP cannot read it, I fear there must be something special with your HDF5 file.

Marco Peters, thank you for your immediately reply. h5 has different type!
i use a conversion software to transform the .h5 file to multiple .tif files(each band as a file), then i use VISAT to read one, unfortunately, there is no GeoCoding information for it, only with image coordinate. however, if i use ENVI or ArcGIS to read it, GeoCoding exists! tif also has different type! oh, this is a chaotic world.
Marco, the class type of the parameter of readProduct() function is String or File, i think there is a little limitation, because the input file must be in local filesystem. if it can support Inputstream class, we can use it in distributed filesystem, such as HDFS . that’s just my own opinion, if wrong, please do not hesitate to correct me.
thanks again.

First to your last point.
We also use SNAP on HDFS and so we know this limitation of not being able to read from streams. But we need to be generic here. Not all readers can read from streams. I think currently it is only the EnvisatProductReader.

But you can explicitly look for a reader and use it directly. The following is code I scribbled down quickly. So no insurance that it is fully correct.

   Iterator<ProductReaderPlugIn> readerPlugIns = ProductIOPlugInManager.getInstance().getReaderPlugIns("FORMAT_NAME");
    ProductReaderPlugIn plugin = null;
    while (readerPlugIns.hasNext()) {
        ProductReaderPlugIn next = readerPlugIns.next();
        Class[] inputTypes = next.getInputTypes();
        for (Class inputType : inputTypes) {
            boolean supportsStreams = InputStream.class.isAssignableFrom(inputType);
            if (supportsStreams && next.getDecodeQualification(inStream)){// takes object as input
                plugin = next;
                break;
            }
        }
    }
    if(plugin == null) {
        throw new Exception("No reader found");
    }
    ProductReader reader = plugin.createReaderInstance();
    Product product = reader.readProductNodes(inStream, null);

Can you post such a tif file so I can have look at?

Marco, thank you for your code. i have altered the tif reader and now it is able to read tif file from HDFS.

the tif file you need is here:
Uploading…
file is olny 2.9M, but Uploading always stops at 100%, if failed, please tell me.

thanks again.

The upload did not work. I’ve send you a private message with a location where you can upload it.