Java Charset Create getEncoder(String encoding)

Here you can find the source of getEncoder(String encoding)

Description

get Encoder

License

Apache License

Declaration

public static final CharsetEncoder getEncoder(String encoding) 

Method Source Code

//package com.java2s;
// Apache License

import java.nio.charset.Charset;

import java.nio.charset.CharsetEncoder;
import java.util.HashMap;

public class Main {
    private static final HashMap charsets = new HashMap();

    public static final CharsetEncoder getEncoder(String encoding) {
        return getCharset(encoding).newEncoder();
    }/*from w ww.  j a va 2  s.co  m*/

    static final Charset getCharset(String encoding) {
        Charset charset = (Charset) charsets.get(encoding);
        if (charset == null) {
            charset = Charset.forName(encoding);
            charsets.put(encoding, charset);
        }
        return charset;
    }
}

Related

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