org.apache.commons.vfs
Interface RandomAccessContent

All Superinterfaces:
java.io.DataInput, java.io.DataOutput
All Known Implementing Classes:
AbstractRandomAccessContent, AbstractRandomAccessStreamContent, DefaultFileContent.FileRandomAccessContent, FtpRandomAccessContent, HttpRandomAccesContent, LocalFileRandomAccessContent, MonitorRandomAccessContent, RamFileRandomAccessContent, SftpRandomAccessContent

public interface RandomAccessContent
extends java.io.DataOutput, java.io.DataInput

Description

Version:
$Revision: 484946 $ $Date: 2006-12-09 09:18:52 +0100 (Sa, 09 Dez 2006) $
Author:
Mario Ivankovits

Method Summary
 void close()
          Closes this random access file stream and releases any system resources associated with the stream.
 long getFilePointer()
          Returns the current offset in this file.
 java.io.InputStream getInputStream()
          get the input stream
Notice: If you use seek(long) you have to reget the InputStream
 long length()
          Returns the length of this file.
 void seek(long pos)
          Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
 
Methods inherited from interface java.io.DataOutput
write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes
 

Method Detail

getFilePointer

long getFilePointer()
                    throws java.io.IOException
Returns the current offset in this file.

Returns:
the offset from the beginning of the file, in bytes, at which the next read or write occurs.
Throws:
java.io.IOException - if an I/O error occurs.

seek

void seek(long pos)
          throws java.io.IOException
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. The offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.
Notice: If you use getInputStream() you have to reget the InputStream after calling seek(long)

Parameters:
pos - the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
Throws:
java.io.IOException - if pos is less than 0 or if an I/O error occurs.

length

long length()
            throws java.io.IOException
Returns the length of this file.

Returns:
the length of this file, measured in bytes.
Throws:
java.io.IOException - if an I/O error occurs.

close

void close()
           throws java.io.IOException
Closes this random access file stream and releases any system resources associated with the stream. A closed random access file cannot perform input or output operations and cannot be reopened.

If this file has an associated channel then the channel is closed as well.

Throws:
java.io.IOException - if an I/O error occurs.

getInputStream

java.io.InputStream getInputStream()
                                   throws java.io.IOException
get the input stream
Notice: If you use seek(long) you have to reget the InputStream

Throws:
java.io.IOException