Java CharsetEncoder .averageBytesPerChar ()

Syntax

CharsetEncoder.averageBytesPerChar() has the following syntax.

public final float averageBytesPerChar()

Example

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


// w w  w . ja v  a2  s  .  c  o m
import java.nio.CharBuffer;
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.averageBytesPerChar());
  }
}




















Home »
  Java Tutorial »
    java.nio.charset »




Charset
CharsetDecoder
CharsetEncoder
StandardCharsets