Skip to content

Commit

Permalink
added delete files on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandalorian committed Nov 15, 2019
1 parent 6f41553 commit 864b298
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,17 @@ public void start(final Stage mainStage) throws Exception {
mainStage.setScene(scene);
mainStage.show();
}


/**
* Clean up on exit
*/
@Override
public void stop() throws Exception{
System.out.println("Started Stop method");
controller.cleanup();
System.out.println("Finished Stop method");
}

/**
* @param args the command line arguments
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URL;
import java.nio.file.Files;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Random;
import java.util.ResourceBundle;
Expand Down Expand Up @@ -621,7 +620,18 @@ private void handleClose(ActionEvent event) {

void cleanup() {
for (File file : targetFileNameList){
file.deleteOnExit();
try{
System.out.println("deleting " + file.getCanonicalPath());
}
catch (Exception e){
System.out.println("something is wrong!");
}

try {
Files.delete(file.toPath());
} catch (Exception e) {
System.out.print(e);
}
}
}

Expand Down

0 comments on commit 864b298

Please sign in to comment.