我正在處理項目,並在其中創建程序以在系統中創建文件夾。當我運行我的程序它顯示:java程序無法在system.why中創建文件夾?
java.io.FileNotFoundException:文件 'E:\ PROGRAM 文件\ IBM \ SDP \ PROFIN \ EmailAttachment \ 30189 \ 31609 \ T0000021811.pdf' 並不 不存在
我的代碼是:
public EmailQueueAttachment[] get(Long emailQueueId)throws InvalidDAOArgumentException {
if (emailQueueId == null) {
throw new InvalidDAOArgumentException("Email Queue Id can not be null.");
}
EmailQueueAttachmentListHelper criteria = new EmailQueueAttachmentListHelper();
criteria.setEmailQueueId(emailQueueId);
List<Model> emailQueueAttachmentList = getList(criteria, -1, -1).getCurrentPageData();
if (emailQueueAttachmentList != null) {
EmailQueueAttachment[] attachments = (EmailQueueAttachment[]) emailQueueAttachmentList.toArray(new EmailQueueAttachment[emailQueueAttachmentList.size()]);
for(int i=0; i<attachments.length; i++){
try {
attachments[i].setAttachmentContent(FileUtils.readFileToByteArray(new File(SystemUtil.getEmailAttachmentFolderName() + File.separator + emailQueueId + File.separator + attachments[i].getRecNo() + File.separator + attachments[i].getAttachmentName())));
} catch (IOException e) {
e.printStackTrace();
throw new DAOException(e);
}
}
return attachments;
}
return null;
}
嗯...首先我想upvote ...但後來我讀代碼,發現一個'readFileToByteArray()' - 沒有幫助在這裏創建父目錄... – Jan