获取Activit流程bpmn和png文件

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盘根目录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值