docs: @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;
      }