Repository navigation
Expand file tree
/
Copy pathuse.html
More file actions
169 lines (145 loc) · 7.47 KB
/
Copy pathuse.html
File metadata and controls
169 lines (145 loc) · 7.47 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="NCSA Java-based Products Home Page -- Visit this site to get the latest NCSA Java-based Products free.">
<meta name="keywords" content="java hdf 5 interface,">
<meta name="distribution" content="global">
<meta name="GENERATOR" content="Mozilla/4.72 [en] (Windows NT 5.0; U) [Netscape]">
<meta name="Description" content="NCSA Java-based Products Home Page -- Visit this site to get the latest NCSA Java-based Products free.">
<meta name="KeyWords" content="java hdf object">
<title>HDF Object Package</title>
<!-- BEGIN MAIN BODY -->
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
<center><table BORDER=0 CELLSPACING=0 CELLPADDING=5 >
<tr>
<td><a href="http://hdf.ncsa.uiuc.edu/"><img SRC="http://hdf.ncsa.uiuc.edu/image/hdf2.jpg" ALT="NCSA HDF home" NOSAVE height=72 width=92></a></td>
<td>
<h1>
NCSA HDF Object Package</h1>
<center><font face="arial,helvetica"><font color="#C80028"><font size=+0><a href="#DOWNLOAD">[Download]</a><a href="javadocs/index.html">[HDF
Object Javadocs]</a></font></font></font></center>
</td>
</tr>
</table></center>
<dd>
<hr noshade size=1></dd>
<h2>
How to use it</h2>
The HDF Object Package is used by Java applications to access HDF4 and
HDF5 files without directly calling the HDF4 and HDF5 library APIs. Library
calls are encapsulated into respective classes. The HDF Object Package
requires the
<a href="../JNI/jhi/index.html">The Java HDF Interface (JHI)</a>
and
<a href="../JNI/jhi5/index.html">The Java HDF5 Interface (JHI5)</a>.
Figure 2 shows the relationship of the packages.
<center>
<p><img SRC="hdf-obj.jpg" height=850 width=700>
<p><b>Figure 2. The Software packages</b></center>
<p>The following examples show how to retreve the file hierarchy.
<h3>
Example 1: retrieve and print HDF5 objects</h3>
<pre>import ncsa.hdf.object.*; // include the HDF object package
import ncsa.hdf.hdf5lib.*; // include the Java HDF5 interface
/**
* Retreve and print HDF5 objects from file <a href="hdf5_test.h5">hdf5_test.h5
</a> * @version 1.3.0 10/26/2001
* @author Peter X. Cao
*
*/
public class TestH5File
{
public static void main(String[] argv)
{
// create an H5File object
H5File h5file = new H5File("hdf5_test.h5", HDF5Constants.H5F_ACC_RDONLY);
try
{
// open file and retrieve the file structure
h5file.open();
}
catch (Exception ex)
{
System.out.println(ex);
}
javax.swing.tree.MutableTreeNode root = h5file.getRootNode();
if (root != null)
{
printNode(root, " ");
}
try { h5file.close(); }
catch (Exception ex ) {}
}
// print out the data ojbect recusively
private static void printNode(javax.swing.tree.TreeNode node, String indent)
{
System.out.println(indent+node);
int n = node.getChildCount();
for (int i=0; i<n; i++)
{
printNode(node.getChildAt(i), indent+" ");
}
}
}</pre>
<h3>
Example 2: retrieve and print HDF4 objects</h3>
<pre>import ncsa.hdf.object.*; // include the HDF object package
import ncsa.hdf.hdflib.*; // include the Java HDF5 interface
/**
* Retreve and print HDF4 objects from file <a href="annras.hdf">annras.hdf</a>.
* @version 1.3.0 10/26/2001
* @author Peter X. Cao
*
*/
public class TestH4File
{
public static void main(String[] argv)
{
// create an H4File object
H4File h4file = new H4File("annras.hdf", HDFConstants.DFACC_READ);
try
{
// open file and retrieve the file structure
h4file.open();
}
catch (Exception ex)
{
System.out.println(ex);
}
javax.swing.tree.MutableTreeNode root = h4file.getRootNode();
if (root != null)
{
printNode(root, " ");
}
try { h4file.close(); }
catch (Exception ex ) {}
}
// print out the data ojbect recusively
private static void printNode(javax.swing.tree.TreeNode node, String indent)
{
System.out.println(indent+node);
int n = node.getChildCount();
for (int i=0; i<n; i++)
{
printNode(node.getChildAt(i), indent+" ");
}
}
}
</pre>
<p><br>For details of how to the whole hierarchy is retrieved from file,
read <a href="H4File.java.txt">H4File.java</a> and <a href="H5File.java.txt">H5File.java</a>.
<br>
<hr SIZE=1 WIDTH="100%">
<p><i>December 20, 2001</i>
<br><!-- BEGIN OF FOOTER INFO -->
<p><a href="http://www.ncsa.uiuc.edu/"><img SRC="http://www.ncsa.uiuc.edu/Images/NCSAhome/footerlogo.gif" ALT="NCSA" NOSAVE BORDER=0 height=27 width=78></a>
<br><font face="arial,helvetica"><font size=-1><a href="http://www.ncsa.uiuc.edu/">The
National Center for Supercomputing Applications</a></font></font>
<br><font face="arial,helvetica"><font size=-1><a href="http://www.uiuc.edu/">University
of Illinois at Urbana-Champaign</a></font></font>
<p><font face="arial,helvetica"><font size=-1><a href="mailto:hdfhelp@ncsa.uiuc.edu">hdfhelp@ncsa.uiuc.edu</a></font></font><!- END OF FOOTER INFO -->
</body>
</html>