-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathH5FileCreate.java
More file actions
executable file
·64 lines (57 loc) · 2.64 KB
/
Copy pathH5FileCreate.java
File metadata and controls
executable file
·64 lines (57 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*****************************************************************************
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of the HDF Java Products distribution. *
* The full copyright notice, including terms governing use, modification, *
* and redistribution, is contained in the files COPYING and Copyright.html. *
* COPYING can be found at the root of the source code distribution tree. *
* Or, see http://hdfgroup.org/products/hdf-java/doc/Copyright.html. *
* If you do not have access to either file, you may request a copy from *
* [email protected]. *
****************************************************************************/
import ncsa.hdf.object.*; // the common object package
import ncsa.hdf.object.h5.*; // the HDF5 implementation
/**
* <p>Title: HDF Object Package (Java) Example</p>
* <p>Description: This example shows how to create an empty HDF5 file using
* the "HDF Object Package (Java)". If the file (H5FileCreate.h5) already
* exists, it will be truncated to zero length.
* </p>
*
* @author Peter X. Cao
* @version 2.4
*/
public class H5FileCreate
{
// The name of the file we'll create.
private static String fname = "H5FileCreate.h5";
public static void main( String args[] ) throws Exception
{
// Retrieve an instance of the implementing class for the HDF5 format
FileFormat fileFormat =
FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF5);
// If the implementing class wasn't found, it's an error.
if (fileFormat == null)
{
System.err.println("Cannot find HDF5 FileFormat.");
return;
}
// If the implementing class was found, use it to create a new HDF5 file
// with a specific file name.
//
// If the specified file already exists, it is truncated.
// The default HDF5 file creation and access properties are used.
//
H5File testFile = (H5File)fileFormat.createFile(fname,
FileFormat.FILE_CREATE_DELETE);
// Check for error condition and report.
if (testFile == null)
{
System.err.println("Failed to create file: "+fname);
return;
}
// End of example that creates an empty HDF5 file named H5FileCreate.h5.
}
}