Here you can find the source of png2jpeg(File pngImage, File jpegFile)
public static boolean png2jpeg(File pngImage, File jpegFile)
//package com.java2s; //License from project: Open Source License import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; public class Main { public static boolean png2jpeg(File pngImage, File jpegFile) { BufferedImage bufferedImage; try {/* w w w . j av a 2 s .c o m*/ bufferedImage = ImageIO.read(pngImage); BufferedImage newBufferedImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_INT_RGB); newBufferedImage.createGraphics().drawImage(bufferedImage, 0, 0, Color.WHITE, null); ImageIO.write(bufferedImage, "jpg", jpegFile); return true; } catch (IOException e) { e.printStackTrace(); return false; } } }