|
@@ -0,0 +1,50 @@
|
|
|
+package org.jeecg.modules.appInterface;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+
|
|
|
+public class ImageUtil {
|
|
|
+
|
|
|
+
|
|
|
+ public static FileInputStream readImage(String path) throws IOException {
|
|
|
+ return new FileInputStream(new File(path));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void readBin2Image(InputStream in, String targetPath) {
|
|
|
+ File file = new File(targetPath);
|
|
|
+ String path = targetPath.substring(0, targetPath.lastIndexOf("/"));
|
|
|
+ if (!file.exists()) {
|
|
|
+ new File(path).mkdir();
|
|
|
+ }
|
|
|
+ FileOutputStream fos = null;
|
|
|
+ try {
|
|
|
+ fos = new FileOutputStream(file);
|
|
|
+ int len = 0;
|
|
|
+ byte[] buf = new byte[1024];
|
|
|
+ while ((len = in.read(buf)) != -1) {
|
|
|
+ fos.write(buf, 0, len);
|
|
|
+ }
|
|
|
+ fos.flush();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (null != fos) {
|
|
|
+ try {
|
|
|
+ fos.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|