How read variable length byte array from hdf java

I am unable to read HDF5 file using Java HDF5 interface which is written
using C library.

The dataset i am trying to read is a compund type containing
H5T_NATIVE_ULONG, varray_type = H5Tvlen_create (H5T_NATIVE_CHAR) fields.

I am using following code to read it using java api.

FileFormat fileFormat = FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF5);
// open the file with read and write access
FileFormat testFile =, FileFormat.READ);
// open the file and retrieve the file structure;
Group root = (Group)((javax.swing.tree.DefaultMutableTreeNode)testFile.

for(int i=0; i<root.getMemberList().size(); i++)
Dataset dataset = (Dataset)root.getMemberList().get(i);
java.util.List<Object> dataRead = (java.util.List<Object>);
long[] sid = (long[]) dataRead.get(0);
String[] rec = (String[]) dataRead.get(1);
System.out.println( sid[0]);
System.out.println( rec[0]);


Its working. But As you can see variable length array is returned as string.
I had to trim and tokenize to use it.

Why it is giving string where it is actually a byte array? Is there a way I
can get it as byte array?