title: How to chunk List<Object> in Netty
body: <p>When sending file, you can do <code>ctx.writeAndFlush(new ChunkedFile(new File("file.png")));</code>.</p>
  
  <p>how about a <code>List&lt;Object&gt;</code>?</p>
  
  <p>The list contains <code>String</code> and <code>bytes of image</code>.  </p>
  
  <p>from the documentation there's <code>ChunkedInput()</code> but I'm not able to get the use of it.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>let's say in my Handler, inside <code>channelRead0(ChannelHandlerContext ctx, Object o)</code> method where I want to send the <code>List&lt;Object&gt;</code> I've done the following</p>
  
  <pre><code>@Override
  protected void channelRead0(ChannelHandlerContext ctx, Object o) throws Exception {
  
     List&lt;Object&gt; msg = new ArrayList&lt;&gt;();
  
     /**getting the bytes of image**/
     byte[] imageInByte;
     BufferedImage originalImage = ImageIO.read(new File(fileName));
     // convert BufferedImage to byte array
     ByteArrayOutputStream bAoS = new ByteArrayOutputStream();
     ImageIO.write(originalImage, "png", bAoS);
     bAoS.flush();
     imageInByte = baos.toByteArray();
     baos.close();
  
     msg.clear();
     msg.add(0, "String"); //add the String into List
     msg.add(1, imageInByte); //add the bytes of images into list
  
     /**Chunk the List&lt;Object&gt; and Send it just like the chunked file**/
     ctx.writeAndFlush(new ChunkedInput(DONT_KNOW_WHAT_TO_DO_HERE)); //
  
  }
  </code></pre>