Package org.apache.camel.support.builder
Class OutputStreamBuilder
java.lang.Object
java.io.OutputStream
org.apache.camel.support.builder.OutputStreamBuilder
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Utility to hide the complexity of choosing which OutputStream implementation to choose.
Itself masquerades as an OutputStream, but really delegates to a CachedOutputStream or a ByteArrayOutputStream.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the result of using this builder as either aCachedOutputStream
if stream caching is enabled, otherwise byte[].void
close()
void
flush()
static OutputStreamBuilder
withExchange
(org.apache.camel.Exchange exchange) Creates a new OutputStreamBuilder with the current exchangevoid
write
(byte[] b) void
write
(byte[] b, int off, int len) void
write
(int b) Methods inherited from class java.io.OutputStream
nullOutputStream
-
Method Details
-
withExchange
Creates a new OutputStreamBuilder with the current exchange Use thebuild()
when writing to the stream is finished, and you need the result of this operation.- Parameters:
exchange
- the current Exchange- Returns:
- the builder
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
build
Builds the result of using this builder as either aCachedOutputStream
if stream caching is enabled, otherwise byte[].- Throws:
IOException
-