怎么将在程序中处理后的一张图片保存到本地计算机.现有 image 图片 和保存文件路径 path变量。那位大师傅帮帮忙呀!能给出代码吗?
 public void save_as(){
 if(Tools.jcbIsSelected(jcbdata)){
 if(jFileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){
 save_as(jFileChooser.getSelectedFile());
 }
 } else{
 JOptionPane.showMessageDialog(null, "请选择保存的文件的复选框!!", "error of operation!", JOptionPane.INFORMATION_MESSAGE);
}
 }
 
 private void save_as(File file){
 String path = file.toString();  下面该怎么写,帮帮忙吧!  }

解决方案 »

  1.   

    你的图片实现是在内存中?
    使用ImageIO类可以实现把内存中的Image对象保存成文件
      

  2.   

    http://www.java2s.com/Code/Java/2D-Graphics-GUI/Image-IO.htm
    例子到是很好,不过看得头痛。更简单的一些是,直接用:ImageIO的方法
    static boolean write(RenderedImage im, String formatName, File output) 
              Writes an image using an arbitrary ImageWriter that supports the given format to a File. 
    static boolean write(RenderedImage im, String formatName, ImageOutputStream output) 
              Writes an image using the an arbitrary ImageWriter that supports the given format to an ImageOutputStream. 
    static boolean write(RenderedImage im, String formatName, OutputStream output) 
              Writes an image using an arbitrary ImageWriter that supports the given format to an OutputStream. 
      

  3.   

    初学java 还没弄那么高深,望将详细点!感激不尽!