You need to sign in to do that
Don't have an account?
learnSF
ArrayIndexOutofBoundException in Base64 conversation in java
hi,
I want to decode attahcment body into normal string.I wrote code like this.
I am getting attachment body from salesforce data base.
I have checked in DB that this attachment have body content in data base.
byte encoded[] = Base64.decodeBase64(fullAtt.getBody());
and I am using org.apache.commons.codec.binary.Base64.java class for decode.
Here code is failing and givng ArrayIndexOutofBound exception.
Can anyone give some suggestion on it?
QueryResult qrAtt=binding.query("Select a.SystemModstamp, a.ParentId, a.OwnerId, a.Name, a.LastModifiedDate, a.LastModifiedById, a.IsPrivate, a.IsDeleted, a.Id, a.CreatedDate, a.CreatedById, a.ContentType, a.BodyLength, a.Body From Attachment a where a.id="+" ' "+attId+"'");
Attachment fullAtt=(Attachment)qrAtt.getRecords(0);
byte encoded[] = Base64.decodeBase64(fullAtt.getBody());
System.out.println(encoded.toString());
Its giving me error like
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -43
I read somewhere like this for commans-codec-1.3.jar
Base64.isArrayByteBase64() throws an ArrayIndexOutOfBoundsException for negative octets. Fixes 30825 . Thanks to Piero Ottuzzi .Base64.isArrayByteBase64() throws an ArrayIndexOutOfBoundsException for negative octets. Fixes 30825 . Thanks to Piero Ottuzzi .
and this is fixed in 1.4 SNAPSHOT,But not able to get that jar.
In my case is this a reason for failing?