想对jpeg格式图像进行压缩(不是缩略图),压缩后还是jpeg格式,在java中如何实现

告诉我具体用到哪些类中的哪些方法也行。
[19 byte] By [liuguangliang-小刀刘] at [2008-1-9]
# 1
try {

// 压缩前的JPEG文件
File srcFile = new File("c:\\src.jpg");
// 压缩前后的JPEG文件
File dstFile = new File("c:\\dst.jpg");
// 压缩百分比
float quality = 0.75f;

BufferedImage srcImage = ImageIO.read(srcFile);

Iterator it = ImageIO.getImageWritersBySuffix("jpg");
if (it.hasNext()) {
FileImageOutputStream fileImageOutputStream = new FileImageOutputStream(dstFile);
ImageWriter iw = (ImageWriter) it.next();
ImageWriteParam iwp = iw.getDefaultWriteParam();
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
iwp.setCompressionQuality(quality);
iw.setOutput(fileImageOutputStream);
iw.write(null, new IIOImage(srcImage, null, null), iwp);
iw.dispose();
fileImageOutputStream.flush();
fileImageOutputStream.close();
}
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
# 2
jpeg已经是压缩过的图片了,基本上不能再压缩太多了
ChDw-米 at 2007-10-19 > top of Msdn China Tech,Java,J2SE,基础类...