01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
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 language governing permissions and
15: * limitations under the License.
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 00:18:52 -0800 (Sat, 09 Dec 2006) $
29: */
30: public interface RandomAccessContent extends DataOutput, DataInput {
31: /**
32: * Returns the current offset in this file.
33: *
34: * @return the offset from the beginning of the file, in bytes,
35: * at which the next read or write occurs.
36: * @throws IOException if an I/O error occurs.
37: */
38: public long getFilePointer() throws IOException;
39:
40: /**
41: * Sets the file-pointer offset, measured from the beginning of this
42: * file, at which the next read or write occurs. The offset may be
43: * set beyond the end of the file. Setting the offset beyond the end
44: * of the file does not change the file length. The file length will
45: * change only by writing after the offset has been set beyond the end
46: * of the file.
47: * <br/>
48: * <b>Notice: If you use {@link #getInputStream()} you have to reget the InputStream after calling {@link #seek(long)}</b>
49: *
50: * @param pos the offset position, measured in bytes from the
51: * beginning of the file, at which to set the file
52: * pointer.
53: * @throws IOException if <code>pos</code> is less than
54: * <code>0</code> or if an I/O error occurs.
55: */
56: public void seek(long pos) throws IOException;
57:
58: /**
59: * Returns the length of this file.
60: *
61: * @return the length of this file, measured in bytes.
62: * @throws IOException if an I/O error occurs.
63: */
64: public long length() throws IOException;
65:
66: /**
67: * Closes this random access file stream and releases any system
68: * resources associated with the stream. A closed random access
69: * file cannot perform input or output operations and cannot be
70: * reopened.
71: * <p/>
72: * <p> If this file has an associated channel then the channel is closed
73: * as well.
74: *
75: * @throws IOException if an I/O error occurs.
76: */
77: public void close() throws IOException;
78:
79: /**
80: * get the input stream
81: * <br/>
82: * <b>Notice: If you use {@link #seek(long)} you have to reget the InputStream</b>
83: */
84: public InputStream getInputStream() throws IOException;
85: }
|