# CSJ2K.j2k.codestream.writer.BitOutputBuffer.toByteArray

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="CSJ2K_j2k_codestream_writer_BitOutputBuffer_toByteArray_" data-uid="CSJ2K.j2k.codestream.writer.BitOutputBuffer.toByteArray*">toByteArray Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="CSJ2K_j2k_codestream_writer_BitOutputBuffer_toByteArray_" data-uid="CSJ2K.j2k.codestream.writer.BitOutputBuffer.toByteArray*"></a>
<h4 id="CSJ2K_j2k_codestream_writer_BitOutputBuffer_toByteArray_System_Byte___" data-uid="CSJ2K.j2k.codestream.writer.BitOutputBuffer.toByteArray(System.Byte[])">toByteArray(byte[])</h4>
<div class="markdown level1 summary"><p>Returns the byte buffer data in a new array. This is a copy of the
internal byte buffer. If 'data' is non-null it is used to return the
data. This array should be large enough to contain all the data,
otherwise a IndexOutOfBoundsException is thrown by the Java system. The
number of elements returned is what 'getLength()' returns.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public virtual byte[] toByteArray(byte[] data)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Overridable Function toByteArray(data As Byte()) As Byte()</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.byte">byte</a>[]</td>
      <td><span class="parametername">data</span></td>
      <td><p>If non-null this array is used to return the data, which
mus be large enough. Otherwise a new one is created and returned.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.byte">byte</a>[]</td>
      <td><p>The byte buffer data.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
