private static final byte[] encodeInteger(Integer integer)
    {
        int num_digits = 1;
        int int_val = integer.intValue();
        while((int_val /= 10) > 0)
            ++num_digits;
        int_val = integer.intValue();
        byte[] bencoded_integer = new byte[num_digits+2];
        bencoded_integer[0] = (byte)'i';
        bencoded_integer[bencoded_integer.length - 1] = (byte)'e';
        for(int i = num_digits; i > 0; i--)
        {
            bencoded_integer[i] = (byte)((int_val % 10)+48);
            int_val /= 10;
        }
        return bencoded_integer;
    }