org.apache.commons.vfs
Class RACRandomAccessFile

java.lang.Object
  extended by java.io.RandomAccessFile
      extended by org.apache.commons.vfs.RACRandomAccessFile
All Implemented Interfaces:
java.io.Closeable, java.io.DataInput, java.io.DataOutput, RandomAccessContent

public class RACRandomAccessFile
extends java.io.RandomAccessFile
implements RandomAccessContent

Encapsulates a RandomAccessContent instance, allowing it to be used as a RandomAccessFile instance.

Version:
1.1, $LastChangedRevision: 1163 $, $LastChangedDate: 2006-12-13 03:18:57 +0000 (Qua, 13 Dez 2006) $
Author:
Elifarley Callado Coelho Cruz

Field Summary
protected  byte[] singleByteBuf
           
 
Constructor Summary
RACRandomAccessFile(RandomAccessContent rac)
           
 
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.
 long length()
          Returns the length of this file.
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void seek(long pos)
          Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
 void setLength(long newLength)
           
 int skipBytes(int n)
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.RandomAccessFile
getChannel, getFD, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.DataOutput
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
 

Field Detail

singleByteBuf

protected final byte[] singleByteBuf
Constructor Detail

RACRandomAccessFile

public RACRandomAccessFile(RandomAccessContent rac)
                    throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getFilePointer

public long getFilePointer()
                    throws java.io.IOException
Description copied from interface: RandomAccessContent
Returns the current offset in this file.

Specified by:
getFilePointer in interface RandomAccessContent
Overrides:
getFilePointer in class java.io.RandomAccessFile
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

public void seek(long pos)
          throws java.io.IOException
Description copied from interface: RandomAccessContent
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 RandomAccessContent.getInputStream() you have to reget the InputStream after calling RandomAccessContent.seek(long)

Specified by:
seek in interface RandomAccessContent
Overrides:
seek in class java.io.RandomAccessFile
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.

skipBytes

public int skipBytes(int n)
              throws java.io.IOException
Specified by:
skipBytes in interface java.io.DataInput
Overrides:
skipBytes in class java.io.RandomAccessFile
Throws:
java.io.IOException

length

public long length()
            throws java.io.IOException
Description copied from interface: RandomAccessContent
Returns the length of this file.

Specified by:
length in interface RandomAccessContent
Overrides:
length in class java.io.RandomAccessFile
Returns:
the length of this file, measured in bytes.
Throws:
java.io.IOException - if an I/O error occurs.

setLength

public void setLength(long newLength)
               throws java.io.IOException
Overrides:
setLength in class java.io.RandomAccessFile
Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Description copied from interface: RandomAccessContent
Get the input stream.
Notice: If you use RandomAccessContent.seek(long) you have to reget the InputStream

Specified by:
getInputStream in interface RandomAccessContent
Returns:
the InputStream.
Throws:
java.io.IOException - if an I/O error occurs.

close

public void close()
           throws java.io.IOException
Description copied from interface: RandomAccessContent
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.

Specified by:
close in interface java.io.Closeable
Specified by:
close in interface RandomAccessContent
Overrides:
close in class java.io.RandomAccessFile
Throws:
java.io.IOException - if an I/O error occurs.

read

public final int read(byte[] b)
               throws java.io.IOException
Overrides:
read in class java.io.RandomAccessFile
Throws:
java.io.IOException
See Also:
RandomAccessFile.read(byte[])

read

public final int read()
               throws java.io.IOException
Overrides:
read in class java.io.RandomAccessFile
Throws:
java.io.IOException
See Also:
RandomAccessFile.read()

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.RandomAccessFile
Throws:
java.io.IOException

write

public final void write(int b)
                 throws java.io.IOException
Specified by:
write in interface java.io.DataOutput
Overrides:
write in class java.io.RandomAccessFile
Throws:
java.io.IOException
See Also:
RandomAccessFile.write(int)

write

public final void write(byte[] b)
                 throws java.io.IOException
Specified by:
write in interface java.io.DataOutput
Overrides:
write in class java.io.RandomAccessFile
Throws:
java.io.IOException
See Also:
RandomAccessFile.write(byte[])

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Specified by:
write in interface java.io.DataOutput
Overrides:
write in class java.io.RandomAccessFile
Throws:
java.io.IOException
See Also:
RandomAccessFile.write(byte[],int,int)


Copyright © 2002-2009 Apache Software Foundation. All Rights Reserved.