A hint for use with Java

Dear users of the hdf5lib interface of hdf-java,

As a little hint, I've found it handy to use the "import static" feature of Java so as to use function and constant names directly. That is, if you write

import static ncsa.hdf.hdf5lib.H5.*;
import static ncsa.hdf.hdf5lib.HDF5Constants.*;

then you can write, for example,

        int fapl_id = H5Pcreate(H5P_FILE_ACCESS);

instead of

        int fapl_id = H5.H5Pcreate(HDF5Constants.H5P_FILE_ACCESS);

This could be helpful when porting C examples for Java.
Pardon me if this was already obvious to you...

Best Regards,
  Vesa Paatero

=== Original message follows ===


Date: Mon, 12 Apr 2010 16:33:27 -0500
From: Peter Cao <xcao@hdfgroup.org>
To: HDF Users Discussion List <hdf-forum@hdfgroup.org>
Subject: Re: [Hdf-forum] HDF5 -writing to memory in Java question
Message-ID: <4BC391A7.3000409@hdfgroup.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

We don't have any Java example. If you have the HDF5 source code, you
should be able to find
some C examples at the "test/" directory. If you are using the HDF5 Java
wrapper, you can follow
the C examples and write your own Java example. Something like

        int fapl_id = H5.H5Pcreate(HDF5Constants.H5P_FILE_ACCESS);
        H5.H5Pset_fapl_core(fapl_id, 1024, true);

The core driver was not tested in HDF5 Java.


Nigel Pickard wrote:

I'm currently evaluating HDF5 for use with Java to store datasets.
Using the examples given, I have no problem in creating an HDF file
that represents a simple example Java object. However, instead of
writing the data to a file and incurring the costs of File I/O, I'd
like to write the data to memory instead (ultimately to a data stream
but for test purpose writing the data to memory as an object would be
fine). Is there a good Java example for this? Is it possible? Or can
I only use Java to write to files?

If anyone has sample code showing this for a simple Java object, I
would be more than grateful.

Hdf-forum is for HDF software users discussion.