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 Object
build()
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 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:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(int b) throws IOException
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
build
public Object build() throws IOException
Builds the result of using this builder as either aCachedOutputStream
if stream caching is enabled, otherwise byte[].- Throws:
IOException
-
-