//1.获取仓库对象
RepositoryService rs = processEngine.getRepositoryService();
//2.使用部署ID查询,此处默认为601
String deploymentId = "601";
//3.获取该部署下的所有资源名称
List<String> list = rs.getDeploymentResourceNames(deploymentId);
//4.查询结尾是PNG的资源名称
//定义图片资源的名称,后缀为PNG的是我们要查找的资源
String resourceName = "";
if(list!=null && list.size()>0){
for(String name:list){
if(name.indexOf(".png")>=0){
resourceName = name;
}
}
}
//5.获取图片的输入流
InputStream in = rs.getResourceAsStream(deploymentId, resourceName);
//6.将图片生成到D盘的目录下
File file = new File("D:/" + resourceName);
FileUtils.copyInputStreamToFile(in, file);
发表评论: