标签:ace ima tst Fix red nal stream block finally
BufferedImage image_to_save = null; try { image_to_save = ImageIO.read(new File("d:\\123.jpg")); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } FileOutputStream fos = null; ImageWriter imageWriter = null; ImageOutputStream ios = null; try { fos = new FileOutputStream("d:\\124.jpg"); imageWriter = ImageIO.getImageWritersBySuffix("jpg").next(); ios = ImageIO.createImageOutputStream(fos); imageWriter.setOutput(ios); JPEGImageWriteParam jpegParams = (JPEGImageWriteParam) imageWriter.getDefaultWriteParam(); jpegParams.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); jpegParams.setCompressionQuality(0.3f); imageWriter.write(null, new IIOImage(image_to_save, null, null), jpegParams); } catch (Exception ex) { } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { } } if (ios != null) { try { ios.close(); } catch (IOException e) { } } if (imageWriter != null) { imageWriter.dispose(); } }
标签:ace ima tst Fix red nal stream block finally
原文地址:https://www.cnblogs.com/merseyalma/p/10506701.html