java - Linux: How to save a image using ImageIO.write()? -
i writing screen capture program on linux using java. how can use imageio.write()
used on windows like:
imageio.write(screenshot, "png", new file("c:/output.png"));
if you're writing screen capture program, want use filechooser allow user choose output file.
here's simple example of how implement one:
jfilechooser jfc = new jfilechooser(); int returnval = jfc.showsavedialog(); if(returnval == jfilechooser.approve_option) { file outputfile = jfc.getselectedfile(); imageio.write(screenshot, "png", outputfile); }
this make code cross-platform, instead of hard-coding platform-specific paths program.
Comments
Post a Comment