1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 * Copyright by The HDF Group. * 3 * Copyright by the Board of Trustees of the University of Illinois. * 4 * All rights reserved. * 5 * * 6 * This file is part of HDF5. The full HDF5 copyright notice, including * 7 * terms governing use, modification, and redistribution, is contained in * 8 * the COPYING file, which can be found at the root of the source code * 9 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * 10 * If you do not have access to either file, you may request a copy from * 11 * help@hdfgroup.org. * 12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 13 14 /************************************************************ 15 Creating and closing a file. 16 ************************************************************/ 17 18 package examples.intro; 19 20 import hdf.hdf5lib.H5; 21 import hdf.hdf5lib.HDF5Constants; 22 23 public class H5_CreateFile { 24 static final String FILENAME = "H5_CreateFile.h5"; 25 CreateFile()26 private static void CreateFile() { 27 long file_id = -1; 28 29 // Create a new file using default properties. 30 try { 31 file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT, 32 HDF5Constants.H5P_DEFAULT); 33 } 34 catch (Exception e) { 35 e.printStackTrace(); 36 } 37 38 // Close the file. 39 try { 40 if (file_id >= 0) 41 H5.H5Fclose(file_id); 42 } 43 catch (Exception e) { 44 e.printStackTrace(); 45 } 46 47 } 48 main(String[] args)49 public static void main(String[] args) { 50 H5_CreateFile.CreateFile(); 51 } 52 53 } 54