+ Start a Discussion

How to use Byte in Apex?

Hi All,


I'm new to salesforce and trying to learn apex. In apex it does not support byte and Bitbuffer so how could we implement this, for instance I have a java snippet

/* BitBuffer */
public void write(BitBuffer buffer) {

        char[] c = getData().toCharArray();

        int i = 0;

        while (i + 1 < c.length) {
            buffer.put(getCode(c[i]) * 12 + getCode(c[i + 5]), 41);
            i += 5;
        if (i < c.length) {
            buffer.put(getCode(c[i]), 6);

 Could any one tell me how can I implement in Apex.





You don't have the concept of bytes or chars in Apex, the closest you can get is a one line String.    You may want to take a look at the Apex Lang code share at http://code.google.com/p/apex-lang/, as this has a Character class that may satisfy your requirements.