1.查询一次部署对应的流程定义文件名称和对应的输入流(bpmn png)
/**
* 查询一次部署对应的流程定义文件名称和对应的输入流(bpmn png)
*
* @throws Exception
*/
@Test
public void test1() throws Exception {
String deploymentId = "501";
List<String> names = processEngine.getRepositoryService()
.getDeploymentResourceNames(deploymentId);
for (String name : names) {
System.out.println(name);
InputStream in = processEngine.getRepositoryService()
.getResourceAsStream(deploymentId, name);
// 将文件保存到本地磁盘
/*
* OutputStream out = new FileOutputStream(new File("d:\\" + name));
* byte[] b = new byte[1024]; int len = 0; while((len =
* in.read(b))!=-1) { out.write(b, 0, len); } out.close();
*/
FileUtils.copyInputStreamToFile(in, new File("d:\\" + name));
in.close();
}
}
结果:bpmn和png文件下载至D盘根目录
2.只获得png文件的输入流
/**
* 获得png文件的输入流
*
* @throws Exception
*/
@Test
public void test2() throws Exception {
String processDefinitionId = "qjlc:3:504";
InputStream pngInputStream = processEngine.getRepositoryService()
.getProcessDiagram(processDefinitionId);
FileUtils.copyInputStreamToFile(pngInputStream, new File("d:\\my.png"));
}
结果:png文件下载至D盘根目录