1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs;
18
19 import java.io.DataInput;
20 import java.io.DataOutput;
21 import java.io.IOException;
22 import java.io.InputStream;
23
24 /***
25 * Description
26 *
27 * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
28 * @version $Revision: 484946 $ $Date: 2006-12-09 09:18:52 +0100 (Sa, 09 Dez 2006) $
29 */
30 public interface RandomAccessContent extends DataOutput, DataInput
31 {
32 /***
33 * Returns the current offset in this file.
34 *
35 * @return the offset from the beginning of the file, in bytes,
36 * at which the next read or write occurs.
37 * @throws IOException if an I/O error occurs.
38 */
39 public long getFilePointer() throws IOException;
40
41 /***
42 * Sets the file-pointer offset, measured from the beginning of this
43 * file, at which the next read or write occurs. The offset may be
44 * set beyond the end of the file. Setting the offset beyond the end
45 * of the file does not change the file length. The file length will
46 * change only by writing after the offset has been set beyond the end
47 * of the file.
48 * <br/>
49 * <b>Notice: If you use {@link #getInputStream()} you have to reget the InputStream after calling {@link #seek(long)}</b>
50 *
51 * @param pos the offset position, measured in bytes from the
52 * beginning of the file, at which to set the file
53 * pointer.
54 * @throws IOException if <code>pos</code> is less than
55 * <code>0</code> or if an I/O error occurs.
56 */
57 public void seek(long pos) throws IOException;
58
59 /***
60 * Returns the length of this file.
61 *
62 * @return the length of this file, measured in bytes.
63 * @throws IOException if an I/O error occurs.
64 */
65 public long length() throws IOException;
66
67 /***
68 * Closes this random access file stream and releases any system
69 * resources associated with the stream. A closed random access
70 * file cannot perform input or output operations and cannot be
71 * reopened.
72 * <p/>
73 * <p> If this file has an associated channel then the channel is closed
74 * as well.
75 *
76 * @throws IOException if an I/O error occurs.
77 */
78 public void close() throws IOException;
79
80 /***
81 * get the input stream
82 * <br/>
83 * <b>Notice: If you use {@link #seek(long)} you have to reget the InputStream</b>
84 */
85 public InputStream getInputStream() throws IOException;
86 }