You may have to use the Java wrapper. Below is the sample code that
writes any
data (pdf, excel, tiff, video, etc) into HDF5 using opaque.
===============
private boolean createH5Dataset(int h5fid, String h5dsetName,
String srcFilename)
throws Exception {
int did = -1, tid = -1, sid = -1;
long size = (new File(srcFilename)).length();
long dims[] = {size};
if (size <=0)
return false; // nothing to write
tid = H5.H5Tcreate (HDF5Constants.H5T_OPAQUE, 1);
H5.H5Tset_tag (tid, "Content-Type: application/pdf");
//H5.H5Tset_tag (tid, "Content-Type: application/vnd.ms-excel");
// H5.H5Tset_tag (tid, "Content-Type: video/mp4");
sid = H5.H5Screate_simple (1, dims, null);
did = H5.H5Dcreate (h5fid, h5dsetName, tid, sid,
HDF5Constants.H5P_DEFAULT);
BufferedInputStream bufferedInput = null;
byte[] buffer = new byte[(int)size];
bufferedInput = new BufferedInputStream(new
FileInputStream(srcFilename));
bufferedInput.read(buffer);
H5.H5Dwrite (did, tid, HDF5Constants.H5S_ALL,
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, buffer);
try {
H5.H5Tclose(tid);
} catch (HDF5Exception ex) {
}
try {
H5.H5Sclose(sid);
} catch (HDF5Exception ex) {
}
try {
H5.H5Dclose(did);
} catch (HDF5Exception ex) {
}
return (did > 0);
}
=================================
return (did > 0);
}
======================
On 3/22/2011 8:53 AM, Konrad Hinsen wrote:
Does anyone have a working code example that creates an opaque
datatype and a dataset of that type using the HDF Object Package
(high-level Java interface)? I get nothing but mysterious exceptions,
whatever I try.
Thanks in advance,
Konrad.
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org