All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.greencheek.caching.herdcache.memcached.util.AsciiStringToBytes Maven / Gradle / Ivy

Go to download

A cache that uses futures to prevent thundering herds to your backend service

There is a newer version: 2.0.19
Show newest version
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