public boolean isLegalReplacement(byte[] replacement){
  if (decoder == null) {
    decoder=charset.newDecoder();
    decoder.onMalformedInput(CodingErrorAction.REPORT);
    decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
  }
  ByteBuffer in=ByteBuffer.wrap(replacement);
  CharBuffer out=CharBuffer.allocate((int)(replacement.length * decoder.maxCharsPerByte()));
  CoderResult result=decoder.decode(in,out,true);
  return !result.isError();
}

public boolean isLegalReplacement ( byte [ ] replacement ) { if ( decoder == null ) { decoder = charset . newDecoder ( ) ; decoder . onMalformedInput ( CodingErrorAction . REPORT ) ; decoder . onUnmappableCharacter ( CodingErrorAction . REPORT ) ; } ByteBuffer in = ByteBuffer . wrap ( replacement ) ; CharBuffer out = CharBuffer . allocate ( ( int ) ( replacement . length * decoder . maxCharsPerByte ( ) ) ) ; CoderResult result = decoder . decode ( in , out , true ) ; return ! result . isError ( ) ; }
tests whether the given argument is legal as this encoder ' s replacement byte array . the given byte array is legal if and only if it can be decoded into characters .
