ewe.io
Interface RandomAccessStream

All Superinterfaces:
BasicRandomAccessStream, BasicStream, Stream
All Known Implementing Classes:
RandomStreamObject

public interface RandomAccessStream
extends BasicRandomAccessStream, Stream


Method Summary
 int getFilePosition()
          Deprecated. use tell() instead.
 int getLength()
          Deprecated. use length() instead.
 long length()
          Get the current length of the stream.
 boolean seek(int pos)
          Deprecated. use seek(long pos) instead.
 void seek(long position)
          Set the stream position.
 void setLength(long newLength)
          Set the length of the RandomAccessStream if possible.
 long tell()
          Get the current stream position.
 RandomStream toRandomStream()
           
 
Methods inherited from interface ewe.io.BasicRandomAccessStream
canWrite, getStreamLength, nonBlockingRead, nonBlockingWrite, seekPosition, setStreamLength, tellPosition
 
Methods inherited from interface ewe.io.BasicStream
close, closeStream, flushStream, isOpen, nonBlockingRead, nonBlockingWrite
 
Methods inherited from interface ewe.io.Stream
flush, read, read, read, readBytes, readBytes, toInputStream, toOutputStream, write, write, write, writeBytes, writeBytes
 

Method Detail

getLength

public int getLength()
Deprecated. use length() instead.

Gets the length of the open stream. This is a blocking call

Returns:
the length of the stream.

seek

public boolean seek(int pos)
Deprecated. use seek(long pos) instead.

Set the file position. This is a blocking call.

Parameters:
pos - The new file position to set.
Returns:
true on success, false on failure or error.

getFilePosition

public int getFilePosition()
Deprecated. use tell() instead.

Get the file position. This is a blocking call.

Returns:
The file position.

seek

public void seek(long position)
          throws IOException
Set the stream position. This is a blocking call.

Parameters:
position - The position to seek to.
Throws:
IOException - if an error occurs while seeking.

tell

public long tell()
          throws IOException
Get the current stream position. This is a blocking call.

Returns:
the current stream position.
Throws:
IOException - if an error occurs.

length

public long length()
            throws IOException
Get the current length of the stream. This is a blocking call.

Returns:
the current length of the stream.
Throws:
IOException - if an error occurs.

setLength

public void setLength(long newLength)
               throws IOException
Set the length of the RandomAccessStream if possible. This is a blocking call. If the operation could not be performed at all an IOException will be thrown.

Make no assumptions about the success of this method. Not all RAS objects will support setStreamLength() or setLength() - not even all Files on all systems will support this. For example, PersonalJava/Java 1.1 does not support this feature and will throw an IOException.

What happens to the file position pointer after this method is called is unpredictable, especially if you are truncating the file. You should ALWAYS reset the file position pointer after calling this method to be where you wish it to be.

Throws:
IOException

toRandomStream

public RandomStream toRandomStream()