FileOutputStream Class

  • java.lang.Object
    • OutputStream
      • com.microsoft.azure.storage.file.FileOutputStream

public class FileOutputStream

The class is an append-only stream for writing into storage.

Constructor Summary

Constructor Description
FileOutputStream(final CloudFile parentFile, final long length, final AccessCondition accessCondition, final FileRequestOptions options, final OperationContext opContext)

Initializes a new instance of the FileOutputStream class.

Method Summary

Modifier and Type Method and Description
void close()

Closes this output stream and releases any system resources associated with this stream. If any data remains in the buffer it is committed to the service.

synchronized void flush()

Flushes this output stream and forces any buffered output bytes to be written out. If any data remains in the buffer it is committed to the service.

void write(final byte[] data)

Writes bytes from the specified byte array to this output stream.

void write(final byte[] data, final int offset, final int length)

Writes length bytes from the specified byte array starting at offset to this output stream.

void write(final InputStream sourceStream, final long writeLength)

Writes all data from the InputStream to the File.

void write(final int byteVal)

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Constructor Details

FileOutputStream

protected FileOutputStream(final CloudFile parentFile, final long length, final AccessCondition accessCondition, final FileRequestOptions options, final OperationContext opContext)

Initializes a new instance of the FileOutputStream class.

Parameters:

parentFile - A CloudFile object which represents the file that this stream is associated with.
length - A long which represents the length of the file in bytes.
accessCondition - An AccessCondition object which represents the access conditions for the file.
options - A FileRequestOptions object which specifies any additional options for the request.
opContext - An OperationContext object which is used to track the execution of the operation

Throws:

StorageException - An exception representing any error which occurred during the operation.

Method Details

close

public void close()

Closes this output stream and releases any system resources associated with this stream. If any data remains in the buffer it is committed to the service.

Throws:

IOException - If an I/O error occurs.

flush

public synchronized void flush()

Flushes this output stream and forces any buffered output bytes to be written out. If any data remains in the buffer it is committed to the service.

Throws:

IOException - If an I/O error occurs.

write

public void write(final byte[] data)

Writes bytes from the specified byte array to this output stream.

Parameters:

data - A byte array which represents the data to write.

Throws:

IOException - If an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.

write

public void write(final byte[] data, final int offset, final int length)

Writes length bytes from the specified byte array starting at offset to this output stream.

Parameters:

data - A byte array which represents the data to write.
offset - An int which represents the start offset in the data.
length - An int which represents the number of bytes to write.

Throws:

IOException - If an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.

write

public void write(final InputStream sourceStream, final long writeLength)

Writes all data from the InputStream to the File.

Parameters:

sourceStream - An InputStream object which species the data to write to the File.
writeLength

Throws:

IOException - If an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
StorageException - An exception representing any error which occurred during the operation.

write

public void write(final int byteVal)

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters:

byteVal - An int which represents the bye value to write.

Throws:

IOException - If an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.

Applies to