zoukankan      html  css  js  c++  java
  • 图片转流

        /**
         * 图片转流
         *
         * @param imgpath
         * @return
         * @throws Exception
         */
        public String byte2Base64String(String imgpath) throws Exception {
            byte[] buffer = null;
            if (null != imgpath && !"".equals(imgpath.toString().trim())) {
                File file = new File(imgpath);
                FileInputStream fis = new FileInputStream(file);
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                byte[] b = new byte[1024];
                int n;
                while ((n = fis.read(b)) != -1) {
                    bos.write(b, 0, n);
                }
                fis.close();
                bos.close();
                buffer = bos.toByteArray();
                Blob serialBlob = new SerialBlob(buffer);
                InputStream binaryStream = serialBlob.getBinaryStream();
                byte[] input2byte = FileUtil.input2byte(binaryStream);
                String imageString = ImageUtil.imageByte2String(input2byte);
                return imageString;
            } else {
                return null;
            }
        }
  • 相关阅读:
    ElasticSearch-生命周期管理
    Alpha 冲刺五
    Alpha 冲刺四
    Alpha 冲刺三
    Alpha 冲刺二
    Alpha 冲刺一
    测试随笔
    校友录
    项目需求分析(淘校)
    团队选题报告(淘校)
  • 原文地址:https://www.cnblogs.com/diandianquanquan/p/10640667.html
Copyright © 2011-2022 走看看