Java Charset Create getEncoder()

Here you can find the source of getEncoder()

Description

get Encoder

License

Open Source License

Declaration

public static CharsetEncoder getEncoder() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;

public class Main {
    private static final String ENCODING = "UTF-8";

    public static CharsetEncoder getEncoder() {
        final CharsetEncoder encoder;

        if (Charset.isSupported(ENCODING)) {
            // UTF-8 is supported by system
            encoder = Charset.forName(ENCODING).newEncoder();
        } else {//w  w  w  .j a v  a  2s  .  c  o  m
            // Use default.
            encoder = Charset.defaultCharset().newEncoder();
        }

        return encoder;
    }
}

Related

  1. getDefaultSystemCharset()
  2. getEncodedStringLength(String str)
  3. getEncodedUrl(String unEncodedUrl)
  4. getEncoder()
  5. getEncoder()
  6. getEncoder(String encoding)
  7. getEncoding(byte[] htmlData)
  8. getEncoding(OutputStreamWriter inWriter)
  9. getEncoding(String text)