Package com.azure.storage.common
Class StorageOutputStream
java.lang.Object
java.io.OutputStream
com.azure.storage.common.StorageOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
StorageOutputStream allows for uploading data to an Azure Storage service using stream concepts.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IOExceptionHolds the last exception this stream encountered. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStorageOutputStream(int writeThreshold) Creates a new instance ofStorageOutputStream. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidHelper function to check if the stream is faulted, if it is it surfaces the exception.voidclose()Closes this output stream and releases any system resources associated with this stream.dispatchWrite(byte[] data, int writeLength, long offset) Dispatches a write operation to the Storage service.voidflush()Flushes this output stream and forces any buffered output bytes to be written out.voidwrite(byte[] data) Writesb.lengthbytes from the specified byte array to this output stream.voidwrite(byte[] data, int offset, int length) Writes length bytes from the specified byte array starting at offset to this output stream.voidwrite(int byteVal) Writes the specified byte to this output stream.protected voidwriteInternal(byte[] data, int offset, int length) Writes the data to the buffer and triggers writes to the service as needed.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
lastError
Holds the last exception this stream encountered.
-
-
Constructor Details
-
StorageOutputStream
protected StorageOutputStream(int writeThreshold) Creates a new instance ofStorageOutputStream.- Parameters:
writeThreshold- How many bytes the output will retain before it initiates a write to the Storage service.
-
-
Method Details
-
dispatchWrite
Dispatches a write operation to the Storage service.- Parameters:
data- The data to send.writeLength- Length of the data.offset- The offset to write the data.- Returns:
- A reactive response that indicates completion.
-
writeInternal
protected void writeInternal(byte[] data, int offset, int length) Writes the data to the buffer and triggers writes to the service as needed.- Parameters:
data- Abytearray which represents the data to write.offset- Anintwhich represents the start offset in the data.length- Anintwhich represents the number of bytes to write.
-
checkStreamState
protected void checkStreamState()Helper function to check if the stream is faulted, if it is it surfaces the exception.- Throws:
RuntimeException- If an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
-
flush
public 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.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream
-
write
Writesb.lengthbytes from the specified byte array to this output stream.- Overrides:
writein classOutputStream- Parameters:
data- Abytearray which represents the data to write.
-
write
Writes length bytes from the specified byte array starting at offset to this output stream.- Overrides:
writein classOutputStream- Parameters:
data- Abytearray which represents the data to write.offset- Anintwhich represents the start offset in the data.length- Anintwhich represents the number of bytes to write.- Throws:
IndexOutOfBoundsException- when access the bytes out of the bound.
-
write
public void write(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.trueis acceptable for you.- Specified by:
writein classOutputStream- Parameters:
byteVal- Anintwhich represents the byte value to write.
-
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.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- If an I/O error occurs.
-