public class ChunkOutputStream extends AsyncOutputStream
DefaultHttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
HttpHeaders.setTransferEncodingChunked(response);
response.headers().set(CONTENT_TYPE, "application/octet-stream");
//other headers
ctx.write(response);
// code of the application that use the ChunkOutputStream
// Don't forget to close the ChunkOutputStream after use!
ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT).addListener(ChannelFutureListener.CLOSE);
| Modifier and Type | Method and Description |
|---|---|
CompletionStage<Void> |
asyncFlush()
Flushes this async output stream.
|
CompletionStage<Void> |
asyncWrite(byte[] bytes,
int offset,
int length)
Writes to this async output stream.
|
void |
close() |
void |
flush() |
void |
reset() |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
asyncWritewritepublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void reset()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic CompletionStage<Void> asyncFlush()
AsyncOutputStreamasyncFlush in class AsyncOutputStreamCompletionStage notified on completion of the flush operation.public CompletionStage<Void> asyncWrite(byte[] bytes, int offset, int length)
AsyncOutputStreamasyncWrite in class AsyncOutputStreambytes - the bytes to writeoffset - the offset from which to start writing in the given byte array.length - the number of bytes to write from the given byte arrayCompletionStage notified on completion of the write operation.Copyright © 2021 JBoss by Red Hat. All rights reserved.