View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      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 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  }