What’s the cleanest way to determine if a dataset existing using the Java API. I’m currently using the following; however, I prefer not to use exception handling this way.
private boolean exists(long fileId, String dataset)
{
long datasetId = -1L;
try
{
datasetId = H5.H5Dopen(fileId, dataset, HDF5Constants.H5P_DEFAULT);
}
catch (HDF5LibraryException | NullPointerException ex)
{
// do nothing
}
finally
{
try
{
H5.H5Dclose(datasetId);
}
catch (HDF5LibraryException ex)
{
// do nothing
}
}
return datasetId != -1L;
}