public static String getbyte(int var, int num)
    {
        StringBuffer tstring = new StringBuffer();
        if (num == 2)
        {
            int b1 = var & 0xff;
            int b2 = (var >> 8) & 0xff;
            tstring.appendCodePoint(b1);
            tstring.appendCodePoint(b2);
            return tstring.toString();

        }
        else
        {
            if (num == 4)
            {
                int b1 = var & 0xff;
                int b2 = (var >> 8) & 0xff;
                int b3 = (var >> 16) & 0xff;
                int b4 = (var >> 24) & 0xff;
                tstring.appendCodePoint(b1);
                tstring.appendCodePoint(b2);
                tstring.appendCodePoint(b3);
                tstring.appendCodePoint(b4);
                return tstring.toString();
            }
        }
        return null;
    }