A simple screen capture program can Capture screenshots of the system. Share with you.
Package COM. shine. framework. screendump; import Java. AWT. dimension; import Java. AWT. rectangle; import Java. AWT. robot; import Java. AWT. toolkit; import Java. AWT. image. bufferedimage; import Java. io. file; import javax. imageIO. imageIO;/*** screenshot program ** @ author viruscodecn@gmail.com **/public class screendumphelper {Private Static string defaultimageformat = "jpg "; /*** screenshot ** @ Param filename * @ Param Format * @ Pa Ram x * @ Param y * @ Param width * @ Param height * @ throws exception */public static void snapshot (string filename, string format, int X, int y, int width, int height) throws exception {dimension D = NULL; try {d = toolkit. getdefatooltoolkit (). getscreensize (); // copy the screen to a bufferedimage object screenshotbufferedimage screenshot = (new robot ()). createscreencapture (New rectangle (X, Y, width, height); // according to the file prefix variables and File Format variable, automatically generate the file name file F = new file (filename); system. out. print ("save file" + filename); // write the screenshot object to the image file ImageIO. write (screenshot, format, f); system. out. print (".. finished! \ N ");} catch (exception ex) {Throw ex;} finally {If (D! = NULL) d = NULL;}/** screenshot ** @ Param filename * @ Param Format * @ throws exception */public static void snapshot (string filename, string format) throws exception {dimension D = NULL; try {d = toolkit. getdefatooltoolkit (). getscreensize (); snapshot (filename, format, 0, 0, D. width, D. height);} catch (exception ex) {Throw ex;} finally {If (D! = NULL) d = NULL;}/** screenshot ** @ Param filename * @ throws exception */public static void snapshot (string filename) throws exception {dimension D = NULL; try {d = toolkit. getdefatooltoolkit (). getscreensize (); snapshot (filename, defaultimageformat, 0, 0, D. width, D. height);} catch (exception ex) {Throw ex;} finally {If (D! = NULL) d = NULL ;}} public static void main (string [] A) throws exception {// capture the screendumphelper of the current screen. snapshot ("e :\\ 123.jpg ");}}