Expand my Community achievements bar.

attachments extraction.

Avatar

Level 4
hi all,



my pdf with attachments is working perfectly but the thing is that , when i try to extract the attachments and save it to the local drive , it gets saved as unknown file type. how to extract the attachments.please help...



thanks in advance.
1 Reply

Avatar

Level 4
hi ,



im extracting the attachments using the following code,



...

List Attachments = result.getAttachments();

//Create an Iterator object and iterate through

//the List object

System.out.println("before check of attachments");

Iterator iter = Attachments.iterator();

int i = 0 ;

while (iter.hasNext()) {

//String fileName=Attachments.listIterator(0).toString();

//System.out.println("filename"+fileName);

Document file = (Document)iter.next();

file.copyToFile(new File("D:\\temp\\attachments"+i+""));

i++;

..



the attachments are of type, pdf, text ,jpeg etc... so how should i save the attachments to the drive. kindly help as im very new to this.