从数据库中检索base64字符串,然后尝试将其转换为bytes数组,在第二步中出现以下错误:
Process: com.streamsystem.bomarecompany.syncadapter, PID: 23085
java.lang.NumberFormatException: Invalid int:
/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgoBAgICAgICBQMDBQoHBgcKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCv/AABEIATsDUgMBEQACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APAdN8M3Wj3S3tzZn7JPIBHKDkL8y4Jr4u2plOKS0NHxRq1hp1giPP8AvQCtwFHGC54p21Iculjzjz4NYv7y0kVd8IDxDHpiixDaZ6P4LhijXTr6IEMhOHHUYI6VSSaKTUluSzefdeMbmRGYSOxJwOpwc59+9KK1JjD3jCv1Om3X2+4hR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+zl3mSe3d5WmbkN1yPoKL2MlC2qKkGk3msazbJfxqsNunlyN/EwySCTTLja3vGl4o0PStNsY9ft4iVguCpZj9/sAB6ZyKp7ClL3TzP4kXmvjTkit9NaG2uJJJJf757cnt2qor3jLW9zjH0+WbTzHasWiW2DXC56Nzg/j0+taprceltdyvp6XVjLEUnJWTLrGTktgdCe1KV90J6xOt0LVLWx8GXOkSOiPfTgGPB4UcnPtzUr3pXFzGQ2lWkeoST6fKkQ/1ZiyMsOM5xWuvKEXfS5oeJdK0X7RbzPaSOY2LOok5c7eGB9N1JJ6mkZR1ujBsfDuoXWvyC4n+R0UMz9C561SslcUFvIo6r588t5GYAqQxtHbKh4G0gbvxpp9TOpNyJr+0tZlGmWsQlng2qs2M87QSp9RTTs7mcXzHnepRrFqd84j2lpPmD8HPbitVsbLSOpJqcFs3gtJLpWLy7grKfuc8NQm+ciPmfpl/wbuWUFn8A/jmiBif+Ek8Gbnbv/o/iLFd2Gd1L5fqa0nufdXifxNoPgPwxf8Ajrxdq0NhpGkafPfapfTnCW9vDG0ksjY7KisT9K6d9DU8i0r9qn4wvYaJ8SvE37Keo2PgTXLq0itNStteW61q1t7uRIre6udLjh/dxkyxl1jnlliViWjGxgKcV3A9Zl+LHwn0nx1bfCvXfih4dtPEt9EHsfDd1rdvHf3C9mS3ZxIw9wpqLO1wd0bFl8S/h4LG68QzfEDQ4tIttQexu9WbVoRbRXS3H2
这里是我的转换代码:
temp = image.split(",");
bytesArray = new byte[temp.length];
for (String item: temp) {
bytesArray[index] = Byte.parseByte(item);
index++;
}
我该怎么办呢(对不起base64代码),谢谢!
答案 0 :(得分:1)
从java 8开始,有一个用于base64编码和解码的官方API,这段代码应该可以工作:
import android.util.Base64;
byte[] bytesArray = Base64.decode(item, Base64.DEFAULT);
在此处查看更多信息: https://stackoverflow.com/a/15646871/5529621