Java String Decode by Charset decodeCharset(String value, String charset)

Here you can find the source of decodeCharset(String value, String charset)

Description

decode Charset

License

Open Source License

Declaration

public static String decodeCharset(String value, String charset) 

Method Source Code

//package com.java2s;
/**/*from   w w w.  j  a v  a 2  s. co m*/
 * Copyright (c) 2015 SK holdings Co., Ltd. All rights reserved.
 * This software is the confidential and proprietary information of SK holdings.
 * You shall not disclose such confidential information and shall use it only in
 * accordance with the terms of the license agreement you entered into with SK holdings.
 * (http://www.eclipse.org/legal/epl-v10.html)
 */

import java.nio.ByteBuffer;
import java.nio.charset.Charset;

public class Main {

    public static String decodeCharset(String value, String charset) {
        try {
            Charset set = Charset.forName(charset);
            return set.decode(ByteBuffer.wrap(value.getBytes())).toString();
        } catch (Exception ex) {
            return null;
        }
    }
}

Related

  1. decode(final String str, final Charset charset)
  2. decode(String s, Charset encoding)
  3. decode(String url, Charset charset)
  4. decode(String value, Charset charset)
  5. decode(String value, Charset charset)
  6. decodeComponent(final String s, final Charset charset)
  7. decodeFormFields(final String content, final Charset charset)
  8. decodeURL(@Nullable String str, Charset charSet)
  9. decodeWithDefaultCharSet(String urlToDecode)