We provide examples of writing string data in HDF-Java on this page: http://www.hdfgroup.org/HDF5/examples/api18-java.html
If you go to the very bottom of the page, you will see an example of writing a fixed length string and a variable length string, using both the HDF-Java wrappers and the Object package. If you have questions about these let me know! -Barbara [email protected]<mailto:[email protected]> (Note that the examples expect to be run in the “examples/datasets” directory. Just comment out the “package examples.datasets;” line at the top of the code to run them elsewhere.) From: Hdf-forum [mailto:[email protected]] On Behalf Of Hdfdev Hdfdev Sent: Sunday, October 19, 2014 4:32 PM To: HDF Users Discussion List Subject: [Hdf-forum] How to Write String Object to HDF5? 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.
_______________________________________________ Hdf-forum is for HDF software users discussion. [email protected] http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org Twitter: https://twitter.com/hdf5
