AnsweredAssumed Answered

ArcObjects Java IMemoryBlobStream

Question asked by OCatton on Feb 25, 2015
Latest reply on Feb 26, 2015 by ebrimhall

Hi All,

 

I have written a Java addin tool to open all attachments on a point feature in the PCs default image viewer.

I was using the Working with Attachments, ArcObjects Help for .NET developers , as a starting example to achieve this.

 

But when I use the code snippet below, it successfully loops through all the attachments reading the name

 

ITableAttachments attachTable;
attachTable = new ITableAttachmentsProxy(pFeatureClass);
IAttachmentManager attachMan = attachTable.getAttachmentManager();
ILongArray IdArray = new LongArray();
IdArray.add(OID);
IEnumAttachment attachEnum = attachMan.getAttachmentsByParentIDs(IdArray, true);
attachEnum.reset();
IAttachment attach = attachEnum.next();
while (attach != null){
 System.out.printf("%s,: %s\n", attach.getAttachmentID(), attach.getName() );
 IMemoryBlobStream memBlob = attach.getData();
 memBlob.saveToFile(attach.getName());
 attach = attachEnum.next();
}

 

But it fails to save the IMemoryBlobStream to file with the error,

java.lang.NullPointerException

which implies the blob data was not retrieved from the attachment table.

 

Any pointer on where I am going wrong would be much appreciated,

 

Owain

Outcomes