public class ChunkOutputStream extends OutputStream
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 |
|---|---|
void |
close() |
void |
flush() |
void |
reset() |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
writepublic 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 OutputStreamIOExceptionCopyright © 2021 JBoss by Red Hat. All rights reserved.