org.soyatec.windowsazure.blob.io
Class BlobFileStream

java.lang.Object
  extended by org.soyatec.windowsazure.blob.io.BlobFileStream
All Implemented Interfaces:
BlobStream

public class BlobFileStream
extends java.lang.Object
implements BlobStream


Constructor Summary
BlobFileStream(java.io.File file)
           
BlobFileStream(java.lang.String fileName)
           
 
Method Summary
 boolean canSeek()
          Indicates whether this stream can be seeked.
 void close()
          Close this stream.
 byte[] getBytes()
          Gets the byte array of data that is stored in the stream.
 long getPosition()
          Gets the current position of this stream.
 long length()
          Gets the length of this stream.
 int read(byte[] b)
          Reads some number of bytes from the stream and stores them into the buffer array b.
 int read(byte[] buffer, int offset, int len)
          Reads up to len bytes of data from the stream into an array of bytes.
 void setPosition(long position)
          Sets the current position of this stream.
 void write(byte[] buffer, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlobFileStream

public BlobFileStream(java.io.File file)
               throws java.io.IOException
Throws:
java.io.IOException

BlobFileStream

public BlobFileStream(java.lang.String fileName)
               throws java.io.IOException
Throws:
java.io.IOException
Method Detail

close

public void close()
           throws java.io.IOException
Description copied from interface: BlobStream
Close this stream.

Specified by:
close in interface BlobStream
Throws:
java.io.IOException

length

public long length()
            throws java.io.IOException
Description copied from interface: BlobStream
Gets the length of this stream.

Specified by:
length in interface BlobStream
Returns:
the length of this stream.
Throws:
java.io.IOException

getPosition

public long getPosition()
                 throws java.io.IOException
Description copied from interface: BlobStream
Gets the current position of this stream.

Specified by:
getPosition in interface BlobStream
Returns:
current position of this stream.
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Description copied from interface: BlobStream
Reads some number of bytes from the stream and stores them into the buffer array b.

Specified by:
read in interface BlobStream
Parameters:
b - the buffer into which the data is read.
Returns:
the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException

write

public void write(byte[] buffer,
                  int off,
                  int len)
           throws java.io.IOException
Description copied from interface: BlobStream
Writes len bytes from the specified byte array starting at offset off to this stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

Specified by:
write in interface BlobStream
Parameters:
buffer - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException

canSeek

public boolean canSeek()
Description copied from interface: BlobStream
Indicates whether this stream can be seeked.

Specified by:
canSeek in interface BlobStream
Returns:
true/false

getBytes

public byte[] getBytes()
                throws java.io.IOException
Description copied from interface: BlobStream
Gets the byte array of data that is stored in the stream.

Specified by:
getBytes in interface BlobStream
Returns:
byte array of data that is stored in the stream.
Throws:
java.io.IOException

setPosition

public void setPosition(long position)
                 throws java.io.IOException
Description copied from interface: BlobStream
Sets the current position of this stream.

Specified by:
setPosition in interface BlobStream
Parameters:
position - the current position of this stream.
Throws:
java.io.IOException

read

public int read(byte[] buffer,
                int offset,
                int len)
         throws java.io.IOException
Description copied from interface: BlobStream
Reads up to len bytes of data from the stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

Specified by:
read in interface BlobStream
Parameters:
buffer - the buffer into which the data is read.
offset - the start offset in array b at which the data is written.
len - the maximum number of bytes to read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException