🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
我们可以获取已经部署到数据库中的`.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(); } ``` ![](https://img.kancloud.cn/d4/e6/d4e6ae78257a277ede4bd6f57f104ff4_1278x77.png)