- InputStream in = ((EntityImages)ent).getIcon();
- FileUtil.write(iconFilePath, in);
- in = ((EntityImages)ent).getImage();
- FileUtil.write(productionFilePath, in);
- ent.setValueForProperty("icon_path",getIconStoragePath()+filepath);
- ent.setValueForProperty("publish_path",filepath);
+ OutputStream out;
+ InputStream in = new ByteArrayInputStream(((EntityImages) ent).getIcon());
+ try {
+ File iconFile = new File(iconFilePath);
+
+ FileRoutines.createParentDirectories(iconFile);
+
+ out = new FileOutputStream(iconFile);
+ try {
+ IORoutines.copyStream(in, out);
+ }
+ finally {
+ out.close();
+ }
+ }
+ finally {
+ in.close();
+ }
+
+ in = new ByteArrayInputStream(((EntityImages) ent).getImage());
+ try {
+ File imageFile = new File(productionFilePath);
+
+ FileRoutines.createParentDirectories(imageFile);
+
+ out = new FileOutputStream(imageFile);
+ try {
+ IORoutines.copyStream(in, out);
+ }
+ finally {
+ out.close();
+ }
+ }
+ finally {
+ in.close();
+ }
+
+ ent.setFieldValue("icon_path", getBaseIconStoragePath() + filepath);
+ ent.setFieldValue("publish_path", filepath);