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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -