这个是我的代码  public static String makeImage(String url, int newWidth, int newHeight, String newUrl, String formatName)
throws Exception
{
//读取图片
BufferedImage bi = ImageIO.read(new File(url));
//判断读入图片的宽和高
if (bi.getHeight() > bi.getWidth())
{
//如果高比宽大,就交换两值,确保生成的图片的长个宽都在一个范围内
int tmp = newWidth;
newWidth = newHeight;
newHeight = tmp;
}
//用Image里的方法对图片进行等比压缩,只要宽和高其一值为负,则以正的那个值为最大边进行等比压缩
Image image2 = bi.getScaledInstance(newWidth, newHeight, Image.SCALE_AREA_AVERAGING);
//获取压缩后图片的高和宽
int height = image2.getHeight(null);
int width = image2.getWidth(null);
//FileOutputStream fos = new FileOutputStream(new File(newUrl));
//以新的高和宽构造一个新的缓存图片
BufferedImage bi3 = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi3.createGraphics();
//在新的缓存图片中画图
g.drawImage(image2, 0, 0, null);
//构造IO流输出到文件
FileOutputStream fos = new FileOutputStream(new File(newUrl));
ImageIO.write(bi3, formatName, fos);
fos.close();
return newUrl;
}缩放之后生成的图片什么都没有!!