Java String Encode by Charset charsetForNameOrDefault(String encoding)

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

Description

charset For Name Or Default

License

BSD License

Declaration

public static Charset charsetForNameOrDefault(String encoding) 

Method Source Code

//package com.java2s;
/* Copyright ? 2015 Gerald Rosenberg.
 * Use of this source code is governed by a BSD-style
 * license that can be found in the License.md file.
 *///from ww  w  .j  av  a  2s  . c  om

import java.nio.charset.Charset;

public class Main {
    public static Charset charsetForNameOrDefault(String encoding) {
        Charset charset = (encoding == null) ? Charset.defaultCharset() : Charset.forName(encoding);
        return charset;
    }
}

Related

  1. canEncode(String charset, CharSequence text, String unicodeValue)
  2. canEncode(String sz, String charset)
  3. checkEncoder(CharsetEncoder encoder)
  4. deflate(int level, String str, Charset encoding)
  5. encode(Charset charset, String string)
  6. encode(final String str, final Charset charset)