private static final Object[] decodeString(byte[] bencoded_bytes, int offset) throws BencodingException
    {
        StringBuffer digits = new StringBuffer();
        while(bencoded_bytes[offset] > '/' && bencoded_bytes[offset] < ':')
        {
            digits.append((char)bencoded_bytes[offset++]);
        }
        if(bencoded_bytes[offset] != ':')
        {
            throw new BencodingException("Error: Invalid character at position " + offset + ".\nExpecting ':' but found '" + (char)bencoded_bytes[offset] + "'.");
        }
        offset++;
        int length = Integer.parseInt(digits.toString());
        byte[] byte_string = new byte[length];
        System.arraycopy(bencoded_bytes, offset, byte_string, 0, byte_string.length);
        return new Object[] {new Integer(offset+length), ByteBuffer.wrap(byte_string)};
    }