我們可以獲取已經部署到數據庫中的`.bpmn`以及它對應的流程圖片等數據。
<br/>
**1. 引入 commons-io 依賴**
```xml
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
```
**2. 下載代碼**
```java
@Test
public void downloadResources() throws IOException {
//1、獲取引擎
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
//2、獲取RepositoryService
RepositoryService repositoryService = processEngine.getRepositoryService();
//3、根據流程key獲取ProcessDefinition
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionKey("evectionDeployment")
.singleResult();
//4、獲取部署ID
String deploymentId = processDefinition.getDeploymentId();
//5、構造圖片的InputStream流
String pngName = processDefinition.getDiagramResourceName();
InputStream pngInput = repositoryService.getResourceAsStream(deploymentId, pngName);
//6、構造bpmn文件的InputStream流
String bpmnName = processDefinition.getResourceName();
InputStream bpmnInput = repositoryService.getResourceAsStream(deploymentId, bpmnName);
//7、構造OutputStream流
File pngFile = new File("e:/evectionflow01.png");
File bpmnFile = new File("e:/evectionflow01.bpmn");
FileOutputStream pngOutStream = new FileOutputStream(pngFile);
FileOutputStream bpmnOutStream = new FileOutputStream(bpmnFile);
//8、輸入流,輸出流的轉換
IOUtils.copy(pngInput, pngOutStream);
IOUtils.copy(bpmnInput, bpmnOutStream);
//9、關閉流
pngOutStream.close();
bpmnOutStream.close();
pngInput.close();
bpmnInput.close();
}
```

- Activiti流程引擎
- 工作流介紹
- Activiti是什么
- Activiti流程處理步驟
- Activiti環境搭建
- 搭建步驟
- 表結構介紹
- ActivitiAPI結構
- 認識流程符號
- 流程設計器的使用
- 流程處理步驟
- 亂碼問題
- 流程實例
- 流程實例是什么
- 業務標識
- 查詢流程實例
- 掛起/激活流程實例
- 個人任務
- 分配任務負責人
- 查詢待辦任務
- 辦理權限
- 流程變量
- 流程變量類型
- 流程變量作用域
- 使用流程變量控制流程
- 組任務
- 設置任務候選人
- 組任務辦理流程
- 網關
- 4種網關類型
- 排他網關
- 并行網關
- 包含網關
- 事件網關
- Spring整合Activiti
- SpringBoot整合Activiti
- Flowable流程引擎
- Flowable是什么
- Flowable與Activiti
- Flowable環境搭建
- FlowableAPI
- 流程引擎API與服務
- 流程處理步驟
- 流程部署
- 流程部署方式
- 流程定義版本
- 刪除已部署的流程
- 下載資源
- 流程實例
- 什么是流程實例
- 業務標識
- 查詢流程實例
- 掛起/激活流程實例
- 分配任務負責人
- 固定分配
- UEL表達式分配
- 監聽器分配
- 辦理權限
- 流程變量
- 流程變量類型
- 流程變量作用域
- 流程變量控制流程
- 組任務
- 設置任務候選人
- 組任務辦理流程
- 網關
- 排他網關
- 并行網關
- 包含網關
- 事件網關
- 歷史查詢
- 查詢歷史
- Spring整合Flowable
- 配置文件整合
- 配置類整合
- SpringBoot整合Flowable