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
public final class OutputStreamBuilder extends OutputStream
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectbuild()Builds the result of using this builder as either aCachedOutputStreamif stream caching is enabled, otherwise byte[].voidclose()voidflush()static OutputStreamBuilderwithExchange(org.apache.camel.Exchange exchange)Creates a new OutputStreamBuilder with the current exchangevoidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Method Detail
-
withExchange
public static OutputStreamBuilder withExchange(org.apache.camel.Exchange exchange)
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
public void write(byte[] b, int off, int len) throws IOException- Overrides:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] b) throws IOException- Overrides:
writein classOutputStream- Throws:
IOException
-
write
public void write(int b) throws IOException- Specified by:
writein classOutputStream- Throws:
IOException
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
build
public Object build() throws IOException
Builds the result of using this builder as either aCachedOutputStreamif stream caching is enabled, otherwise byte[].- Throws:
IOException
-
-