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:Main.java

public static byte[] StringToHexBytes(int length, String string) {
    byte[] data = new byte[length];
    byte[] strByte = string.getBytes();
    for (int i = 0; i < strByte.length; i++) {
        data[i] = strByte[i];//from   w  ww  .  j  a v  a2 s  . c o m
    }
    return data;
}

From source file:Main.java

public static void writeNetSocket(Socket socket, String data, int timeoutMS) throws Exception {
    writeNetSocketBytes(socket, data.getBytes(), data.length());
}

From source file:Main.java

/**
 * @param login login name/*from   ww w  . ja va 2 s  . com*/
 * @param pass  password
 * @return  Base64 Auth encoded string
 */
static String getB64Auth(String login, String pass) {
    String source = login + ":" + pass;
    return "Basic " + Base64.encodeToString(source.getBytes(), Base64.URL_SAFE | Base64.NO_WRAP);
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

private static String hashWithAlgorithm(String algorithm, String key) {
    return hashWithAlgorithm(algorithm, key.getBytes());
}

From source file:Main.java

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

From source file:Main.java

public static String decodeUrlToFS(String filename) {
    byte[] bArr = filename.getBytes();
    byte[] bDest = decode(bArr);
    try {// w  w w  .j a  v a  2 s  .c  o m
        return new String(bDest, "utf-8");
    } catch (UnsupportedEncodingException e) {
        return new String(bDest);
    }
}

From source file:com.jk.db.dataaccess.orm.eclipselink.FSSessionPCustomizer.java

/**
 * Encode.//w  ww.  ja v  a2  s .  c o  m
 *
 * @param value
 *            the value
 * @return the string
 */
public static String encode(String value) {
    return new String(Base64.encodeBase64(value.getBytes()));
}