code: @NotNull
      public byte[] getNullTerminatedBytes(int index, int maxLengthBytes) throws IOException
      {
          byte[] buffer = getBytes(index, maxLengthBytes);
  
          // Count the number of non-null bytes
          int length = 0;
          while (length < buffer.length && buffer[length] != 0)
              length++;
  
          if (length == maxLengthBytes)
              return buffer;
  
          byte[] bytes = new byte[length];
          if (length > 0)
              System.arraycopy(buffer, 0, bytes, 0, length);
          return bytes;
      }
docs: Returns the sequence of bytes punctuated by a <code>\0</code> value.
  
  @param index The index within the buffer at which to start reading the string.
  @param maxLengthBytes The maximum number of bytes to read. If a <code>\0</code> byte is not reached within this limit,
  the returned array will be <code>maxLengthBytes</code> long.
  @return The read byte array, excluding the null terminator.
  @throws IOException The buffer does not contain enough bytes to satisfy this request.