org.apache.commons.codec.binary.StringUtils # getBytesUtf8 ( ) 源码实例Demo

下面列出了 org.apache.commons.codec.binary.StringUtils # getBytesUtf8 ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tutorials   文件: StringEncodeUnitTest.java

@Test
public void givenSomeUnencodedString_whenApacheCommonsCodecEncode_thenCompareEquals() {
    String rawString = "Entwickeln Sie mit Vergnügen";
    byte[] bytes = StringUtils.getBytesUtf8(rawString);

    String utf8EncodedString = StringUtils.newStringUtf8(bytes);

    assertEquals(rawString, utf8EncodedString);
}
 

public static byte[] getBytesUtf8(String str) {
    return StringUtils.getBytesUtf8(str);
}
 
源代码3 项目: rya   文件: KeyParts.java

private static void appendPredicate(final Statement statement, final Text keyText) {
       final Value statementValue = new Value(StringUtils.getBytesUtf8(StatementSerializer.writePredicate(statement)));
       final byte[] hashOfValue = uniqueFromValueForKey(statementValue);
       appendBytes(HASH_PREFIX, keyText); // prefix the hash with a zero byte.
       appendBytes(hashOfValue, keyText);
}
 
源代码4 项目: rya   文件: KeyParts.java

private static void appendSubjectPredicate(final Statement statement, final Text keyText) {
       final Value statementValue = new Value(StringUtils.getBytesUtf8(StatementSerializer.writeSubjectPredicate(statement)));
       final byte[] hashOfValue = uniqueFromValueForKey(statementValue);
       appendBytes(HASH_PREFIX, keyText); // prefix the hash with a zero byte.
       appendBytes(hashOfValue, keyText);
}
 
源代码5 项目: rya   文件: TemporalInstantRfc3339.java

@Override
public byte[] getAsKeyBytes() {
    return StringUtils.getBytesUtf8(getAsKeyString());
}
 
源代码6 项目: ews-java-api   文件: IFunctionsTest.java

@Test
public void testBase64Encoder() {
  final byte[] value = StringUtils.getBytesUtf8("123");
  final IFunctions.Base64Encoder f = IFunctions.Base64Encoder.INSTANCE;
  Assert.assertEquals(Base64.encodeBase64String(value), f.func(value));
}
 
源代码7 项目: rya   文件: KeyParts.java

/**
 * Get a collision unlikely hash string and append to the key,
 * so that if two keys have the same value, then they will be the same,
 * if two different values that occur at the same time there keys are different.
 * If the application uses a very large number of statements at the exact same time,
 * the md5 value might be upgraded to for example sha-1 to avoid collisions.
 * @param statement
 * @param keyText
 */
public static void appendUniqueness(final Statement statement, final Text keyText) {
    keyText.append(HASH_PREFIX, 0, 1);   // delimiter
    final Value statementValue = new Value(StringUtils.getBytesUtf8(StatementSerializer.writeStatement(statement)));
    final byte[] hashOfValue = Md5Hash.md5Binary(statementValue);
    keyText.append(hashOfValue, 0, hashOfValue.length);
}
 
源代码8 项目: text_converter   文件: HmacUtils.java

/**
 * Creates an instance using the provided algorithm type.
 *
 * @param algorithm to use
 * @param  key the key to use
 * @throws IllegalArgumentException
 *             when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
 * @since 1.11
 */
public HmacUtils(final String algorithm, final String key) {
    this(algorithm, StringUtils.getBytesUtf8(key));
}
 
源代码9 项目: text_converter   文件: HmacUtils.java

/**
 * Creates an instance using the provided algorithm type.
 *
 * @param algorithm to use
 * @param  key the key to use
 * @throws IllegalArgumentException
 *             when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
 * @since 1.11
 */
public HmacUtils(final HmacAlgorithms algorithm, final String key) {
    this(algorithm.getName(), StringUtils.getBytesUtf8(key));
}
 
源代码10 项目: pivaa   文件: HmacUtils.java

/**
 * Creates an instance using the provided algorithm type.
 *
 * @param algorithm to use
 * @param  key the key to use
 * @throws IllegalArgumentException
 *             when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
 * @since 1.11
 */
public HmacUtils(final String algorithm, final String key) {
    this(algorithm, StringUtils.getBytesUtf8(key));
}
 
源代码11 项目: pivaa   文件: HmacUtils.java

/**
 * Creates an instance using the provided algorithm type.
 *
 * @param algorithm to use
 * @param  key the key to use
 * @throws IllegalArgumentException
 *             when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid.
 * @since 1.11
 */
public HmacUtils(final HmacAlgorithms algorithm, final String key) {
    this(algorithm.getName(), StringUtils.getBytesUtf8(key));
}
 
源代码12 项目: cm_ext   文件: JsonUtil.java

/**
 * Serializes 'data' into a UTF8 byte array.
 * @param data
 * @return
 */
public static byte[] valueAsBytes(Object data) {
  return StringUtils.getBytesUtf8(valueAsString(data));
}