Example usage for java.lang String getBytes

List of usage examples for java.lang String getBytes

Introduction

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

Prototype

public byte[] getBytes() 

Source Link

Document

Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.

Usage

From source file:de.defmacro.dandelion.internal.core.connection.protocol.ProtocolUtilities.java

/**
 * Dekodierung eines String aus Base64.// ww w.  j  a va 2  s  .  c o  m
 * @param base64 - Base64 kodierter String
 * @return
 */
public static String decodeBase64(String base64) {
    return new String(BASE64.decode(base64.getBytes()));
}

From source file:Main.java

public static String encodeToString(String content) {
    try {//from  w  w w  .  j a  v  a 2 s .c om
        return Base64.encodeToString(content.getBytes(), Base64.NO_WRAP);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}

From source file:Main.java

public static boolean isChineseChar(String value) {

    try {//from ww w.  j  a  v a  2  s  .c  o  m
        if (value == null)
            return false;
        char[] chars = value.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            String target = String.valueOf(chars[i]);
            byte[] b = target.getBytes();
            if (b.length == 2) {
            } else {
                return false;
            }
        }
        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static X509Certificate loadCertificate(String certificate) {
    try {/*w w  w. j av a2s. c  om*/
        return loadCertificate(certificate.getBytes());
    } catch (Exception ex) {
        Log.e(TAG, "Failed to parse certificate", ex);
    }

    return null;
}

From source file:Main.java

public static String encryptMD5ToString(String data) {
    return encryptMD5ToString(data.getBytes());
}

From source file:Main.java

public static Element toRootElement(String content) {
    InputStream input = new ByteArrayInputStream(content.getBytes());
    Element root = read(input).getDocumentElement();
    return root;//from  w  w w  . j a  va2  s  .  c o m
}

From source file:com.centurylink.mdw.util.CryptUtil.java

private static byte[] decodeBase64(String inputString) {
    return Base64.decodeBase64(inputString.getBytes());
}

From source file:Main.java

public static byte[] asciiToEbcdic(String s) {
    return asciiToEbcdic(s.getBytes());
}

From source file:br.edu.ufcg.lsd.commune.network.signature.Util.java

public static byte[] decodeStringOnBase64(String str) {
    byte[] encodedBase64 = str.getBytes();
    return decodeArrayOnBase64(encodedBase64);
}

From source file:com.hangum.tadpole.commons.libs.core.utils.Base64Utils.java

/**
 * encode base64 util/*from w ww  .  j  a  va  2s . com*/
 * 
 * @param str
 * @return
 */
public static String base64Encode(String str) {
    byte[] encodedBytes = Base64.encodeBase64(str.getBytes());

    return new String(encodedBytes);
}