code: public final CharsetEncoder replaceWith(byte[] newReplacement) {
          if (newReplacement == null)
              throw new IllegalArgumentException("Null replacement");
          int len = newReplacement.length;
          if (len == 0)
              throw new IllegalArgumentException("Empty replacement");
          if (len > maxBytesPerChar)
              throw new IllegalArgumentException("Replacement too long");
  
          if (!isLegalReplacement(newReplacement))
              throw new IllegalArgumentException("Illegal replacement");
  
          this.replacement = newReplacement;
          implReplaceWith(newReplacement);
          return this;
      }
docs: Changes this encoder's replacement value.
  
  <p> This method invokes the {@link #implReplaceWith implReplaceWith}
  method, passing the new replacement, after checking that the new
  replacement is acceptable.  </p>
  
  @param  newReplacement
  
  
  
  
  
  
  The new replacement; must not be <tt>null</tt>, must have
  non-zero length, must not be longer than the value returned by
  the {@link #maxBytesPerChar() maxBytesPerChar} method, and
  must be {@link #isLegalReplacement </code>legal<code>}
  
  
  @return  This encoder
  
  @throws  IllegalArgumentException
  If the preconditions on the parameter do not hold