}
return 0;
}
public static File getDocFileFromSource(int id) throws Exception {
IDocAttachment attachment = getAttachmentService().getDocAttachmentById(id);
if (attachment == null) {
throw new Exception("Document is not exists!");
}
File docFile = new File(OUTPUT_PATH + id + File.separator + id + "." + attachment.getFileType());
if (docFile.exists() && docFile.isFile()) {
return docFile;
} else if (!docFile.getParentFile().exists()) {
docFile.getParentFile().mkdirs();
}
if (!docFile.exists()) {
docFile.createNewFile();
}
InputStream in = attachment.getContentStream();
OutputStream out = new FileOutputStream(docFile);
byte[] buffer = new byte[1024];
int position = 0;