| | |
| | | package com.matrix.system.hive.plugin.util; |
| | | |
| | | import com.matrix.core.tools.DateUtil; |
| | | import sun.misc.BASE64Decoder; |
| | | |
| | | import java.awt.Image; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.BufferedOutputStream; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public static String base64ToFile(String base64Str, String savePath, String fileName) { |
| | | String fileDir = DateUtil.dateToString(new Date(), DateUtil.DATE_FORMAT_NO_SPLITE_DD); |
| | | |
| | | File dir = new File(savePath + fileDir); |
| | | if (!dir.isDirectory()) { |
| | | dir.mkdir(); |
| | | } |
| | | |
| | | BufferedOutputStream bos = null; |
| | | FileOutputStream fos = null; |
| | | File file = null; |
| | | String filePathAndName = savePath + fileDir + File.separator + fileName; |
| | | BASE64Decoder decoder = new BASE64Decoder(); |
| | | byte[] bfile = new byte[0]; |
| | | try { |
| | | bfile = decoder.decodeBuffer(base64Str); |
| | | file = new File(filePathAndName); |
| | | fos = new FileOutputStream(file); |
| | | bos = new BufferedOutputStream(fos); |
| | | bos.write(bfile); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return filePathAndName; |
| | | } |
| | | |
| | | |
| | | |
| | | |