Help us improve by taking our short survey: https://www.hdfgroup.org/website-survey/

| HDF5 Last Updated on 2026-03-23 The HDF5 Field Guide

Loading...
Searching...
No Matches
Java File (H5F) Interface

## Detailed Description

See also
  Files (H5F), C-API
  HDF5 File, User Guide

## Functions
static synchronized native void | H5Fclear_elink_file_cache (long file_id) throws HDF5LibraryException
static int | H5Fclose (long file_id) throws HDF5LibraryException
static long | H5Fcreate (String name, int flags, long create_id, long access_id) throws HDF5LibraryException, NullPointerException
static synchronized native int | H5Fflush (long object_id, int scope) throws HDF5LibraryException
static long | H5Fget_access_plist (long file_id) throws HDF5LibraryException
static long | H5Fget_create_plist (long file_id) throws HDF5LibraryException
static synchronized native boolean | H5Fget_dset_no_attrs_hint (long file_id) throws HDF5LibraryException
static synchronized native long | H5Fget_fileno (long file_id) throws HDF5LibraryException
static synchronized native long | H5Fget_filesize (long file_id) throws HDF5LibraryException
static synchronized native long | H5Fget_freespace (long file_id) throws HDF5LibraryException
static synchronized native H5F_info2_t | H5Fget_info (long obj_id) throws HDF5LibraryException
static synchronized native int | H5Fget_intent (long file_id) throws HDF5LibraryException
static synchronized native double | H5Fget_mdc_hit_rate (long file_id) throws HDF5LibraryException
static synchronized native void | H5Fget_mdc_logging_status (long file_id, boolean[] mdc_logging_status) throws HDF5LibraryException, NullPointerException
static synchronized native int | H5Fget_mdc_size (long file_id, long[] metadata_cache) throws HDF5LibraryException, NullPointerException, IllegalArgumentException
static synchronized native String | H5Fget_name (long obj_id) throws HDF5LibraryException
static synchronized native long | H5Fget_obj_count (long file_id, int types) throws HDF5LibraryException
static synchronized native long | H5Fget_obj_ids (long file_id, int types, long max_objs, long[] obj_id_list) throws HDF5LibraryException, NullPointerException
static synchronized native boolean | H5Fis_accessible (String name, long fapl_id) throws HDF5LibraryException, NullPointerException
static synchronized native boolean | H5Fis_hdf5 (String name) throws HDF5LibraryException, NullPointerException
static synchronized native int | H5Fmount (long loc_id, String name, long child_id, long plist_id) throws HDF5LibraryException, NullPointerException
static long | H5Fopen (String name, int flags, long access_id) throws HDF5LibraryException, NullPointerException
static long | H5Freopen (long file_id) throws HDF5LibraryException
static synchronized native void | H5Freset_mdc_hit_rate_stats (long file_id) throws HDF5LibraryException
static synchronized native void | H5Fset_dset_no_attrs_hint (long file_id, boolean minimize) throws HDF5LibraryException
static synchronized native void | H5Fset_libver_bounds (long file_id, int low, int high) throws HDF5LibraryException
static synchronized native void | H5Fstart_mdc_logging (long file_id) throws HDF5LibraryException
static synchronized native void | H5Fstart_swmr_write (long file_id) throws HDF5LibraryException
static synchronized native void | H5Fstop_mdc_logging (long file_id) throws HDF5LibraryException
static synchronized native int | H5Funmount (long loc_id, String name) throws HDF5LibraryException, NullPointerException

## Function Documentation

## ◆ H5Fclear_elink_file_cache()

synchronized native void H5Fclear_elink_file_cache | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fclear_elink_file_cache evicts all the cached child files in the specified file's external file cache, causing them to be closed if there is nothing else holding them open.

Parameters

  file_id | IN: Identifier of the target file.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fclose()

int H5Fclose | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fclose terminates access to an HDF5 file.

Parameters

  file_id | Identifier of a file to terminate access to.

Returns
  a non-negative value if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fcreate()

long H5Fcreate | ( | String | name,
|  | int | flags,
|  | long | create_id,
|  | long | access_id ) throws HDF5LibraryException, NullPointerException
| static

H5Fcreate is the primary function for creating HDF5 files.

Parameters

  name | Name of the file to access.
  flags | File access flags. Possible values include: H5F_ACC_RDWR Allow read and write access to file. H5F_ACC_RDONLY Allow read-only access to file. H5F_ACC_TRUNC Truncate file, if it already exists, erasing all data previously stored in the file. H5F_ACC_EXCL Fail if file already exists. H5P_DEFAULT Apply default file access and creation properties.
  create_id | File creation property list identifier, used when modifying default file meta-data. Use H5P_DEFAULT for default access properties.
  access_id | File access property list identifier. If parallel file access is desired, this is a collective call according to the communicator stored in the access_id (not supported in Java). Use H5P_DEFAULT for default access properties.

Returns
  a file identifier if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.
  NullPointerException | name is null.

## ◆ H5Fflush()

synchronized native int H5Fflush | ( | long | object_id,
|  | int | scope ) throws HDF5LibraryException
| static

H5Fflush causes all buffers associated with a file or object to be immediately flushed (written) to disk without removing the data from the (memory) cache.

After this call completes, the file (or object) is in a consistent state and all data written to date is assured to be permanent.

Parameters

  object_id | Identifier of object used to identify the file. object_id can be any object associated with the file, including the file itself, a dataset, a group, an attribute, or a named data type.
  scope | specifies the scope of the flushing action, in the case that the HDF5 file is not a single physical file.

Valid values are:

- H5F_SCOPE_GLOBAL Flushes the entire virtual file.
- H5F_SCOPE_LOCAL Flushes only the specified file.

Returns
  a non-negative value if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_access_plist()

long H5Fget_access_plist | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fget_access_plist returns the file access property list identifier of the specified file.

Parameters

  file_id | Identifier of file to get access property list of

Returns
  a file access property list identifier if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_create_plist()

long H5Fget_create_plist | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fget_create_plist returns a file creation property list identifier identifying the creation properties used to create this file.

Parameters

  file_id | Identifier of the file to get creation property list

Returns
  a file creation property list identifier if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_dset_no_attrs_hint()

synchronized native boolean H5Fget_dset_no_attrs_hint | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fget_dset_no_attrs_hint gets the file-level setting to create minimized dataset object headers.

Parameters

  file_id | IN: Identifier of the target file.

Returns
  true if the file-level is set to create minimized dataset object headers, false if not.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_fileno()

synchronized native long H5Fget_fileno | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fget_fileno retrieves the "file number" for an open file.

Parameters

  file_id | IN: File identifier for a currently-open HDF5 file

Returns
  the unique file number for the file.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_filesize()

synchronized native long H5Fget_filesize | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fget_filesize retrieves the file size of the HDF5 file. This function is called after an existing file is opened in order to learn the true size of the underlying file.

Parameters

  file_id | IN: File identifier for a currently-open HDF5 file

Returns
  the file size of the HDF5 file

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_freespace()

synchronized native long H5Fget_freespace | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fget_freespace returns the amount of space that is unused by any objects in the file.

Parameters

  file_id | IN: File identifier for a currently-open HDF5 file

Returns
  the amount of free space in the file

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_info()

synchronized native H5F_info2_t H5Fget_info | ( | long | obj_id | ) | throws HDF5LibraryException
| static

H5Fget_info returns global information for the file associated with the object identifier obj_id.

Parameters

  obj_id | IN: Object identifier for any object in the file.

Returns
  A buffer(H5F_info2_t) for current "global" information about file

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_intent()

synchronized native int H5Fget_intent | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fget_intent retrieves the intended access mode flag passed with H5Fopen when the file was opened.

Parameters

  file_id | IN: File identifier for a currently-open HDF5 file

Returns
  the intended access mode flag, as originally passed with H5Fopen.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_mdc_hit_rate()

synchronized native double H5Fget_mdc_hit_rate | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fget_mdc_hit_rate queries the metadata cache of the target file to obtain its hit rate (cache hits / (cache hits + cache misses)) since the last time hit rate statistics were reset.

Parameters

  file_id | IN: Identifier of the target file.

Returns
  the double in which the hit rate is returned.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_mdc_logging_status()

synchronized native void H5Fget_mdc_logging_status | ( | long | file_id,
|  | boolean[] | mdc_logging_status ) throws HDF5LibraryException, NullPointerException
| static

H5Fget_mdc_logging_status gets the current metadata cache logging status.

Parameters

  file_id | IN: Identifier of the target file.
  mdc_logging_status | the status mdc_logging_status[0] = is_enabled, whether logging is enabled mdc_logging_status[1] = is_currently_logging, whether events are currently being logged

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.
  NullPointerException | mdc_logging_status is null.

## ◆ H5Fget_mdc_size()

synchronized native int H5Fget_mdc_size | ( | long | file_id,
|  | long[] | metadata_cache ) throws HDF5LibraryException, NullPointerException, IllegalArgumentException
| static

H5Fget_mdc_size queries the metadata cache of the target file for the desired size information.

Parameters

  file_id | IN: Identifier of the target file.
  metadata_cache | OUT: Current metadata cache information metadata_cache[0] = max_size_ptr // current cache maximum size metadata_cache[1] = min_clean_size_ptr // current cache minimum clean size metadata_cache[2] = cur_size_ptr // current cache size

Returns
  current number of entries in the cache

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.
  NullPointerException | metadata_cache is null.

## ◆ H5Fget_name()

synchronized native String H5Fget_name | ( | long | obj_id | ) | throws HDF5LibraryException
| static

H5Fget_name retrieves the name of the file to which the object obj_id belongs.

Parameters

  obj_id | IN: Identifier of the object for which the associated filename is sought.

Returns
  the filename.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_obj_count()

synchronized native long H5Fget_obj_count | ( | long | file_id,
|  | int | types ) throws HDF5LibraryException
| static

H5Fget_obj_count returns the number of open object identifiers for the file.

Parameters

  file_id | IN: File identifier for a currently-open HDF5 file
  types | IN: Type of object for which identifiers are to be returned. H5F_OBJ_FILE Files only H5F_OBJ_DATASET Datasets only H5F_OBJ_GROUP Groups only H5F_OBJ_DATATYPE Named datatypes only H5F_OBJ_ATTR Attributes only H5F_OBJ_ALL All of the above H5F_OBJ_LOCAL Restrict search to objects opened through current file identifier.

Returns
  the number of open objects.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fget_obj_ids()

synchronized native long H5Fget_obj_ids | ( | long | file_id,
|  | int | types,
|  | long | max_objs,
|  | long[] | obj_id_list ) throws HDF5LibraryException, NullPointerException
| static

H5Fget_obj_ids returns the list of identifiers for all open HDF5 objects fitting the specified criteria.

Parameters

  file_id | IN: File identifier for a currently-open HDF5 file
  types | IN: Type of object for which identifiers are to be returned.
  max_objs | IN: Maximum number of object identifiers to place into obj_id_list.
  obj_id_list | OUT: Pointer to the returned list of open object identifiers.

Returns
  the number of objects placed into obj_id_list.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.
  NullPointerException | obj_id_list is null.

## ◆ H5Fis_accessible()

synchronized native boolean H5Fis_accessible | ( | String | name,
|  | long | fapl_id ) throws HDF5LibraryException, NullPointerException
| static

H5Fis_accessible determines if the file can be opened with the given fapl.

Parameters

  name | IN: File name to check.
  fapl_id | IN: File access property list identifier

Returns
  true if file is accessible, false if not.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.
  NullPointerException | name is null.

## ◆ H5Fis_hdf5()

synchronized native boolean H5Fis_hdf5 | ( | String | name | ) | throws HDF5LibraryException, NullPointerException
| static

H5Fis_hdf5 determines whether a file is in the HDF5 format.

Parameters

  name | File name to check format.

Returns
  true if is HDF5, false if not.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.
  NullPointerException | name is null.

Deprecated
  As of HDF5 1.10.5 in favor of H5Fis_accessible.

## ◆ H5Fmount()

synchronized native int H5Fmount | ( | long | loc_id,
|  | String | name,
|  | long | child_id,
|  | long | plist_id ) throws HDF5LibraryException, NullPointerException
| static

H5Fmount mounts the file specified by child_id onto the group specified by loc_id and name using the mount properties plist_id.

Parameters

  loc_id | The identifier for the group onto which the file specified by child_id is to be mounted.
  name | The name of the group onto which the file specified by child_id is to be mounted.
  child_id | The identifier of the file to be mounted.
  plist_id | The identifier of the property list to be used.

Returns
  a non-negative value if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.
  NullPointerException | name is null.

## ◆ H5Fopen()

long H5Fopen | ( | String | name,
|  | int | flags,
|  | long | access_id ) throws HDF5LibraryException, NullPointerException
| static

H5Fopen opens an existing file and is the primary function for accessing existing HDF5 files.

Parameters

  name | Name of the file to access.
  flags | File access flags.
  access_id | Identifier for the file access properties list.

Returns
  a file identifier if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.
  NullPointerException | name is null.

## ◆ H5Freopen()

long H5Freopen | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Freopen reopens an HDF5 file.

Parameters

  file_id | Identifier of a file to terminate and reopen access to.

Returns
  a new file identifier if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Freset_mdc_hit_rate_stats()

synchronized native void H5Freset_mdc_hit_rate_stats | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Freset_mdc_hit_rate_stats resets the hit rate statistics counters in the metadata cache associated with the specified file.

Parameters

  file_id | IN: Identifier of the target file.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fset_dset_no_attrs_hint()

synchronized native void H5Fset_dset_no_attrs_hint | ( | long | file_id,
|  | boolean | minimize ) throws HDF5LibraryException
| static

H5Fset_dset_no_attrs_hint sets the file-level setting to create minimized dataset object headers.

Parameters

  file_id | IN: Identifier of the target file.
  minimize | the minimize hint setting

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fset_libver_bounds()

synchronized native void H5Fset_libver_bounds | ( | long | file_id,
|  | int | low,
|  | int | high ) throws HDF5LibraryException
| static

H5Fset_libver_bounds sets a different low and high bounds while a file is open.

Parameters

  file_id | IN: Identifier of the target file.
  low | IN: The earliest version of the library that will be used for writing objects
  high | IN: The latest version of the library that will be used for writing objects.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fstart_mdc_logging()

synchronized native void H5Fstart_mdc_logging | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fstart_mdc_logging starts logging metadata cache events if logging was previously enabled.

Parameters

  file_id | IN: Identifier of the target file.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fstart_swmr_write()

synchronized native void H5Fstart_swmr_write | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fstart_swmr_write will activate SWMR writing mode for a file associated with file_id. This routine will prepare and ensure the file is safe for SWMR writing.

Parameters

  file_id | IN: Identifier of the target file.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Fstop_mdc_logging()

synchronized native void H5Fstop_mdc_logging | ( | long | file_id | ) | throws HDF5LibraryException
| static

H5Fstop_mdc_logging stops logging metadata cache events if logging was previously enabled and is currently ongoing.

Parameters

  file_id | IN: Identifier of the target file.

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.

## ◆ H5Funmount()

synchronized native int H5Funmount | ( | long | loc_id,
|  | String | name ) throws HDF5LibraryException, NullPointerException
| static

Given a mount point, H5Funmount disassociates the mount point's file from the file mounted there.

Parameters

  loc_id | The identifier for the location at which the specified file is to be unmounted.
  name | The name of the file to be unmounted.

Returns
  a non-negative value if successful

Exceptions

  HDF5LibraryException | Error from the HDF5 Library.
  NullPointerException | name is null.