org.greencheek.caching.herdcache.memcached.util.AsciiStringToBytes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of herdcache Show documentation
Show all versions of herdcache Show documentation
A cache that uses futures to prevent thundering herds to your backend service
package org.greencheek.caching.herdcache.memcached.util;
/**
* Created by dominictootell on 08/06/2014.
*/
public class AsciiStringToBytes {
/**
* See http://java-performance.info/charset-encoding-decoding-java-78/#more-744
*
* @param str the string to obtain the ascii byte array for
* @return the byte array for the ascii string
*/
public static byte[] getBytes( final String str )
{
int len = str.length();
final byte[] res = new byte[len];
for (int i = 0; i < len; i++) {
res[i] = (byte) str.charAt(i);
}
return res;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy