倾家当产寻求图片保存到本地计算机的解决方案

tlqde521i 2007-06-13 11:42:17
怎么将在程序中处理后的一张图片保存到本地计算机.现有 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();

下面该怎么写,帮帮忙吧!

}
...全文
276 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
tlqde521i 2007-06-16
  • 打赏
  • 举报
回复
初学java 还没弄那么高深,望将详细点!感激不尽!
Rellen 2007-06-16
  • 打赏
  • 举报
回复
利用IO流写文件呀,最容易想到的方法了
seesea10523 2007-06-14
  • 打赏
  • 举报
回复
写文件到硬盘上 把路径保存到数据库
edsoft 2007-06-14
  • 打赏
  • 举报
回复
写文件啊!
Inhibitory 2007-06-14
  • 打赏
  • 举报
回复
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.
likgui 2007-06-13
  • 打赏
  • 举报
回复
关注
tlqde521i 2007-06-13
  • 打赏
  • 举报
回复
不懂,能不能说详细一点,谢谢
liujun999999 2007-06-13
  • 打赏
  • 举报
回复
你的图片实现是在内存中?
使用ImageIO类可以实现把内存中的Image对象保存成文件

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧