Hello.
I am new to HDF5 and I would really appreciate if somebody can help me
finding correct approach for the following.
How to write String Object to HDF5 file using native HDF5 java library?
What I am trying?
According to Javadoc java.lang.String is mapped to H5T_C_S1 constant and I
am using it in the following form:
<see screen shot>
private int createDataspace() throws HDF5LibraryException,
HDF5Exception {
return H5.H5Screate_simple(3, new long[]{3, 3, 1}, null);
}
private int createDataset(int fileId, String datasetName) throws
HDF5LibraryException, HDF5Exception {
return H5.H5Dcreate(datasetName,
HDF5Constants.H5T_C_S1, createDataspace(),
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
HDF5Constants.H5P_DEFAULT);
}
private int writeDataset(String fileName, String datasetName,
String[][] table) throws HDF5LibraryException, HDF5Exception {
int datasetId = -1;
int returnCode = H5.H5Dwrite(datasetId = createDataset(fileId ,
datasetName), HDF5Constants.H5T_C_S1,
HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
HDF5Constants.H5P_DEFAULT, table);
H5.H5Dclose(datasetId);
H5.H5Fclose(fileId);
return returnCode;
}
And it throws following exception:
Exception in thread "main" ncsa.hdf.hdf5lib.exceptions.HDF5JavaException:
ArrayDesciptor: Error: String array not supported yet
at
ncsa.hdf.hdf5lib.ArrayDescriptor.<init>(HDFArray.java:1030)
at ncsa.hdf.hdf5lib.HDFArray.<init>(HDFArray.java:68)
at ncsa.hdf.hdf5lib.H5.H5Dwrite(H5.java:1971)
at ncsa.hdf.hdf5lib.H5.H5Dwrite(H5.java:1883)
Thank you.