Interface ResourceWriter
- All Known Implementing Classes:
AbstractResourceWriter,FileResourceWriter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Interface (contract) for writers to define the algorithm or strategy for writing data to a target
Resource,
such as by using the WritableResource's
WritableResource.getOutputStream() OutputStream}.- Since:
- 1.3.1
- See Also:
-
ResourceWritableResource
-
Method Summary
Modifier and TypeMethodDescriptiondefault ResourceWriterthenWriteTo(ResourceWriter writer) Composes thisResourceWriterwith the givenResourceWriterusing the Composite Software Design Pattern.voidwrite(org.springframework.core.io.Resource resource, byte[] data) Writes data to the targetResourceas defined by the algorithm/strategy of this writer.default voidwrite(org.springframework.core.io.Resource resource, ByteBuffer data) Writes data contained in theByteBufferto the targetResourceas defined by the algorithm/strategy of this writer.
-
Method Details
-
write
void write(@NonNull org.springframework.core.io.Resource resource, byte[] data) Writes data to the targetResourceas defined by the algorithm/strategy of this writer. This method should throw anUnhandledResourceExceptionif the algorithm or strategy used by this writer is not able to or capable of writing to theResourceat its location. This allows subsequent writers in a composition to possibly handle theResource. Any otherExceptionthrown by thiswritemethod will break the chain of write calls in the composition.- Parameters:
resource-Resourceto write data to.data- array of bytes containing the data to write to the targetResource.- See Also:
-
Resource
-
write
Writes data contained in theByteBufferto the targetResourceas defined by the algorithm/strategy of this writer. This method should throw anUnhandledResourceExceptionif the algorithm or strategy used by this writer is not able to or capable of writing to theResourceat its location. This allows subsequent writers in a composition to possibly handle theResource. Any otherExceptionthrown by thiswritemethod will break the chain of write calls in the composition.- Parameters:
resource-Resourceto write data to.data-ByteBuffercontaining the data to write to the targetResource.- See Also:
-
ResourceByteBufferwrite(Resource, byte[])
-
thenWriteTo
Composes thisResourceWriterwith the givenResourceWriterusing the Composite Software Design Pattern.- Parameters:
writer-ResourceWriterto compose with this writer.- Returns:
- a composite
ResourceWritercomposed of thisResourceWriterand the givenResourceWriter. If the givenResourceWriteris null, then thisResourceWriteris returned. - See Also:
-