Java CharsetEncoder .isLegalReplacement (byte[] repl)

Syntax

CharsetEncoder.isLegalReplacement(byte[] repl) has the following syntax.

public boolean isLegalReplacement(byte[] repl)

Example

In the following code shows how to use CharsetEncoder.isLegalReplacement(byte[] repl) method.


//  w w  w.j a v a  2  s  .c  om
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;

public class Main {
  public static void main(String[] args) throws Exception{
    CharsetEncoder encoder = Charset.forName("US-ASCII").newEncoder();

    System.out.println(encoder.isLegalReplacement(new byte[]{}));
  }
}




















Home »
  Java Tutorial »
    java.nio.charset »




Charset
CharsetDecoder
CharsetEncoder
StandardCharsets