Java IO Tutorial - Java CharsetEncoder .maxBytesPerChar ()








Syntax

CharsetEncoder.maxBytesPerChar() has the following syntax.

public final float maxBytesPerChar()

Example

In the following code shows how to use CharsetEncoder.maxBytesPerChar() method.

//  w ww  .  ja  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.maxBytesPerChar());
  }
}

The code above generates the following result.