List of usage examples for org.apache.poi.hsmf.datatypes AttachmentChunks getAttachLongFileName
public StringChunk getAttachLongFileName()
From source file:org.silverpeas.core.mail.extractor.MSGExtractor.java
License:Open Source License
@Override public List<MailAttachment> getAttachments() throws MailException { try {/*from ww w . j a v a 2s. c om*/ AttachmentChunks[] attachmentChunks = message.getAttachmentFiles(); List<MailAttachment> mailAttachments = new ArrayList<>(attachmentChunks.length); for (AttachmentChunks attachment : attachmentChunks) { byte[] data = attachment.getAttachData().getValue(); String fileName = attachment.getAttachLongFileName().getValue(); MailAttachment mailAttachment = new MailAttachment(fileName); String dir = FileRepositoryManager.getTemporaryPath() + "mail" + Calendar.getInstance().getTimeInMillis(); File file = new File(dir, fileName); FileUtils.writeByteArrayToFile(file, data); mailAttachment.setPath(file.getAbsolutePath()); mailAttachment.setSize(file.length()); mailAttachments.add(mailAttachment); } return mailAttachments; } catch (IOException e) { throw new MailException(e); } }