Example usage for java.lang String toCharArray

List of usage examples for java.lang String toCharArray

Introduction

In this page you can find the example usage for java.lang String toCharArray.

Prototype

public char[] toCharArray() 

Source Link

Document

Converts this string to a new character array.

Usage

From source file:com.dgq.utils.EncodeUtils.java

/**
 * Hex?./*from w w  w  . j a  va2  s . c om*/
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw new SecurityException("Hex?!");
    }
}

From source file:com.peterchen.core.utils.EncodeUtils.java

/**
 * Hex?./*from ww  w  .  j a  v a2  s . com*/
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw new IllegalArgumentException("Unsupported Encoding Exception", e);
    }
}

From source file:com.pfw.popsicle.common.Encodes.java

/**
 * Hex?./*from  www.j a v  a2 s .  c om*/
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
    }
    return null;
}

From source file:com.thinkgem.jeesite.modules.sso.util.Encodes.java

/**
 * Hex?.//from  w ww. j  a  va2 s.  co m
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        return "".getBytes();
    }
}

From source file:Main.java

/**
 * Returns a new byte array containing the characters of the specified
 * string encoded using the given charset.
 * //from ww  w  .  ja  v a2 s .  co m
 * It is equivalent to <code>input.getBytes(charset)</code> except it has
 * workaround for the bug ID 61917.
 * 
 * @see https://code.google.com/p/android/issues/detail?id=61917
 */
//@formatter:off
/*
 * The original code is available from
 *     https://android.googlesource.com/platform/libcore/+/android-4.4_r1.2/libdvm/src/main/java/java/lang/String.java
 */
//@formatter:on
public static byte[] getBytes(String input, Charset charset) {
    CharBuffer chars = CharBuffer.wrap(input.toCharArray());
    // @formatter:off
    CharsetEncoder encoder = charset.newEncoder().onMalformedInput(CodingErrorAction.REPLACE)
            .onUnmappableCharacter(CodingErrorAction.REPLACE);
    // @formatter:on
    ByteBuffer buffer;
    buffer = encode(chars.asReadOnlyBuffer(), encoder);
    byte[] bytes = new byte[buffer.limit()];
    buffer.get(bytes);
    return bytes;

}

From source file:com.adobe.acs.commons.mcp.impl.processes.asset.NameUtil.java

static String createValidDamName(String title, String[] labelCharMapping, String defaultReplacementCharacter) {
    char[] characters = title.toCharArray();
    StringBuilder name = new StringBuilder(characters.length);

    for (int idx = 0; idx < title.length(); ++idx) {
        char c = title.charAt(idx);
        String replacement = defaultReplacementCharacter;
        if (c < labelCharMapping.length) {
            replacement = labelCharMapping[c];
        }//  w  w w .jav  a2 s .  com

        name.append(replacement);
    }

    return name.toString();
}

From source file:cn.tonghao.remex.business.core.util.security.Encodes.java

/**
 * Hex?./*from w ww  .  java2s. c  om*/
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.net.wx.util.Encodes.java

/**
 * Hex?.//w w  w  . ja v a2  s  .com
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.topsem.common.utils.Encodes.java

/**
 * Hex?.//from  w  w  w  . j a v a  2 s .  co  m
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw Throwables.propagate(e);
    }
}

From source file:com.anybuy.util.EncodeUtil.java

/**
 * Hex?./*from   w w  w  .  ja  v a 2  s  . c o m*/
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw ExceptionUtil.unchecked(e);
    }
}