|
1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 | | -<html> |
3 | | -<head> |
4 | | - <title>Package Documentation for org.apache.avalon.excalibur.io Package</title> |
5 | | -</head> |
6 | | - <body bgcolor="white"> |
7 | | - Utility code for IO operations. <br> |
8 | | -<span style="font-style: italic;">NOTE: Some classes are not yet included |
9 | | -in this description</span><br> |
10 | | -<br> |
11 | | - <a name="doc.Description"></a> |
12 | | -<div align="center"> <a href="#doc.Intro">[Introduction]</a> |
13 | | -<a href="#doc.IOUtils">[IO Utilities]</a> <a href="#doc.FileUtils">[File |
14 | | -Utilities]</a> <a href="#doc.Endian">[Endian Utilities]</a> </div> |
15 | | - <a name="doc.Intro"></a> |
16 | | -<h2>Introduction</h2> |
17 | | - |
18 | | -<p>The <code>org.apache.commons.io</code> package contains utility code for |
19 | | -file- and stream-based IO operation. |
20 | | - </p> |
| 2 | +<!-- |
| 3 | +Copyright 2002-2005 The Apache Software Foundation. |
| 4 | + |
| 5 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +you may not use this file except in compliance with the License. |
| 7 | +You may obtain a copy of the License at |
21 | 8 |
|
| 9 | + http://www.apache.org/licenses/LICENSE-2.0 |
22 | 10 |
|
23 | | - <a name="doc.IOUtils"></a> |
24 | | -<h2>The <a href="IOUtils.html">org.apache.commons.io.IOUtils</a> class</h2> |
25 | | - |
26 | | -<p> The <a href="IOUtils.html">IOUtils</a> class contains a comprehensive |
27 | | -set of static methods for copying from: </p> |
28 | | -<ul> |
29 | | - <li><code>String</code></li> |
30 | | - <li><code>byte[]</code></li> |
31 | | - <li><code>InputStream</code></li> |
32 | | - <li><code>Reader</code></li> |
33 | | - |
34 | | -</ul> |
35 | | - To: |
36 | | -<ul> |
37 | | - <li><code>String</code></li> |
38 | | - <li><code>byte[]</code></li> |
39 | | - <li><code>OutputStream</code></li> |
40 | | - <li><code>Writer</code></li> |
41 | | - |
42 | | -</ul> |
43 | | - |
44 | | -<p></p> |
45 | | - |
46 | | -<p>As an example, consider the task of reading bytes from a URL, and printing |
47 | | -them. This would typically done like this:</p> |
48 | | - |
49 | | -<pre>import java.net.URL;<br>import java.io.*;<br><br>public class ManualCopy {<br> public static void main(String args[]) throws IOException {<br> InputStream in = new URL( "http://jakarta.apache.org" ).openStream();<br> |
50 | | - <b>InputStreamReader inR = new InputStreamReader( in ); |
51 | | - BufferedReader buf = new BufferedReader( inR ); |
52 | | - String line; |
53 | | - while ( ( line = buf.readLine() ) != null ) |
54 | | - { |
55 | | - System.out.println( line ); |
56 | | - }</b> |
57 | | - in.close(); |
58 | | - } |
59 | | -} |
60 | | - </pre> |
61 | | - |
62 | | -<p>With the IOUtils class, that could be done with:</p> |
63 | | - |
64 | | -<pre>import java.net.URL;<br>import java.io.*;<br>import org.apache.commons.io.IOUtils;<br><br>public class IOUtilsCopy {<br> public static void main(String args[]) throws IOException {<br> InputStream in = new URL( "http://jakarta.apache.org" ).openStream();<br> |
65 | | -<b>System.out.println( IOUtils.toString( in ) );</b> |
66 | | - in.close(); |
67 | | - } |
68 | | -} |
69 | | - </pre> |
70 | | - |
71 | | -<p>In certain application domains, such IO operations are common, and this |
72 | | -class can save a great deal of time.</p> |
73 | | - |
74 | | -<p>For utility code such as this, flexibility and speed are of primary importance. |
75 | | -In IOUtils, each kind of copy method has a variant which allows the buffer |
76 | | -size to be set. For methods that convert bytes to chars, the encoding |
77 | | -method may also be set.</p> |
78 | | - <a name="doc.FileUtils"></a> |
79 | | -<h2>The <a href="FileUtils.html">org.apache.commons.io.FileUtils</a> class</h2> |
80 | | - |
81 | | -<p>The <a href="FileUtils.html">FileUtils</a> class contains methods for |
82 | | -retrieving different components of a file path (directory name, file base |
83 | | -name, file extension), methods for copying Files to other files and directories, |
84 | | -and methods for deleting and cleaning directories. For more information, |
85 | | -see the <a href="FileUtils.html">class description</a> </p> |
86 | | - <a name="doc.Endian"></a> |
87 | | -<h2>The Endian classes</h2> |
88 | | - |
89 | | -<p>Different computer architectures adopt different conventions for byte |
90 | | -ordering. In so-called "Little Endian" architectures (eg Intel), the |
91 | | -low-order byte is stored in memory at the lowest address, and subsequent |
92 | | -bytes at higher addresses. For "Big Endian" architectures (eg Motorola), |
93 | | - the situation is reversed.</p> |
94 | | - |
95 | | -<p>There are two classes in this package of relevance: </p> |
96 | | -<ul> |
97 | | - <li>The <a href="EndianUtil.html">org.apache.commons.io.EndianUtil</a> |
98 | | -class contains static methods for swapping the Endian-ness of Java |
99 | | -primitives and streams.</li> |
100 | | - <li>The <a href="input/SwappedDataInputStream.html">org.apache.commons.io.input.SwappedDataInputStream</a> |
101 | | - class is an implementation of the {@link java.io.DataInput} interface. |
102 | | -With this, one can read data from files of non-native Endian-ness.</li> |
103 | | - |
104 | | -</ul> |
105 | | - |
106 | | -<p>For more information, see <a |
107 | | - href="http://www.cs.umass.edu/%7Everts/cs32/endian.html">http://www.cs.umass.edu/~verts/cs32/endian.html</a>. </p> |
108 | | -<br> |
| 11 | +Unless required by applicable law or agreed to in writing, software |
| 12 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +See the License for the specific iouage governing permissions and |
| 15 | +limitations under the License. |
| 16 | +--> |
| 17 | +<html> |
| 18 | +<body bgcolor="white"> |
| 19 | +<p> |
| 20 | +This package defines utility classes for working with streams, readers, |
| 21 | +writers and files. The most commonly used classes are described here: |
| 22 | +</p> |
| 23 | +<p> |
| 24 | +<b>IOUtils</b> is the most frequently used class. |
| 25 | +It provides operations to read, write, copy and close streams. |
| 26 | +</p> |
| 27 | +<p> |
| 28 | +<b>FileUtils</b> provides operations based around the JDK File class. |
| 29 | +These include reading, writing, copying, comparing and deleting. |
| 30 | +</p> |
| 31 | +<p> |
| 32 | +<b>FilenameUtils</b> provides utilities based on filenames. |
| 33 | +This utility class manipulates filenames without using File objects. |
| 34 | +It aims to simplify the transition between Windows and Unix. |
| 35 | +Before using this class however, you should consider whether you should |
| 36 | +be using File objects. |
| 37 | +</p> |
| 38 | +<p> |
| 39 | +<b>FileSystemUtils</b> allows access to the filing system in ways the JDK |
| 40 | +does not support. At present this allows you to get the free space on a drive. |
| 41 | +</p> |
| 42 | +<p> |
| 43 | +<b>EndianUtils</b> swaps data between Big-Endian and Little-Endian formats. |
| 44 | +</p> |
109 | 45 | </body> |
110 | 46 | </html> |
0 commit comments