Helenr
publicstaticBufferedImagetoBufferedImage(Imageimage){if(imageinstanceofBufferedImage){return(BufferedImage)image;}image=newImageIcon(image).getImage();BufferedImagebimage=null;GraphicsEnvironmentge=GraphicsEnvironment.getLocalGraphicsEnvironment();try{inttransparency=Transparency.OPAQUE;GraphicsDevicegs=ge.getDefaultScreenDevice();GraphicsConfigurationgc=gs.getDefaultConfiguration();bimage=gc.createCompatibleImage(image.getWidth(null),image.getHeight(null),transparency);}catch(HeadlessExceptione){}if(bimage==null){inttype=BufferedImage.TYPE_INT_RGB;bimage=newBufferedImage(image.getWidth(null),image.getHeight(null),type);}Graphicsg=bimage.createGraphics();g.drawImage(image,0,0,null);g.dispose();returnbimage;}Imageimage=Toolkit.getDefaultToolkit().createImage(byte[]bytes);BufferedImagebufferedImage=toBufferedImage(image);try{ImageIO.write(bufferedImage,"JPG",newFile("路径"));}catch(IOExceptione){e.printStackTrace();}