do something before exiting the program.
in
Programming Questions
•
1 year ago
Hi all I wonder if anyone can help me solve this small issue I'm having. I have set up a piece of code which transfers a scanned document to a folder. I would like for this file to exist only for the duration of time that the program is open for. After the program shuts, I would like to delete this file. It is only temporary. I'd like to introduce some conditionals to the part of the code which reads:
File f1 = new File("C:/Users/arthur prior/Desktop/OUTPUT/" + "%TEMP%PRESCAN" + "." + FILETYPE.captionLabel());
f1.delete();
something like
if "the program has closed" {
File f1 = new File("C:/Users/arthur prior/Desktop/OUTPUT/" + "%TEMP%PRESCAN" + "." + FILETYPE.captionLabel());
f1.delete()
}
In a way it is a chicken and egg situation, because if the program has terminated then it will not be able to fulfil my request to delete the file...
Any help would be greatly appreciated! Regards, Arthur
- ImageIO.write(bimg, filetype , new File ("C:/Users/arthur prior/Desktop/OUTPUT/" + "%TEMP%PRESCAN" + "." + FILETYPE.captionLabel()));
- class MyCanvas extends ControlWindowCanvas {
- public void draw(PApplet theApplet) {
- PImage OUTPUT = loadImageIO("C:/Users/arthur prior/Desktop/OUTPUT/" + "%TEMP%PRESCAN" + "." + FILETYPE.captionLabel());
- theApplet.image(OUTPUT,0,0);
- OUTPUT.resize(512,731);
- theApplet.image(OUTPUT,0,0);
- File f1 = new File("C:/Users/arthur prior/Desktop/OUTPUT/" + "%TEMP%PRESCAN" + "." + FILETYPE.captionLabel());
- f1.delete();
- }
- }
- controlWindow.addCanvas(new MyCanvas());
- controlWindow.show();
1