bufferedimage 转换成 inputstream并保存文件

BufferedImage img = removeBackgroud(file);//去除重影

//bufferedimage 转换成 inputstream
ByteArrayOutputStream bs = new ByteArrayOutputStream();
ImageOutputStream imOut = ImageIO.createImageOutputStream(bs);
ImageIO.write(img, "jpg", imOut);
InputStream inputStream = new ByteArrayInputStream(bs.toByteArray());

OutputStream outStream = new FileOutputStream("/data/sata/share_sata/AmazonCrawl/amazonWeb/captcha1.jpg");
IOUtils.copy(inputStream, outStream);
inputStream.close();
outStream.close();

posted @ 2016-08-29 09:28  陈泽泽  阅读(2466)  评论(0编辑  收藏  举报