1

I have written a program which creates a MSaccess data base in a temp folder. I need to delete the Tempfolder after download is done at the client side.

@PostConstruct
public void init() {
    try {

        lb.createLbTable(readType());
        Path path = Paths.get(lb.getTempFolder().toString(), "MyDB.accdb");
        this.lbAll = new DefaultStreamedContent(Files.newInputStream(path), "accdb", "MyDB.accdb");

    } catch (IOException e) {
        LOGGER.error(e.getMessage(),e);
    }
}
@PreDestroy
public void destroy() {
    leistungsbereichAccess.deleteTempFolder();
}

And the delete Method from the other class:

    public void deleteTempFolder() {
    try {
        FileUtils.forceDelete(tempFolder.toFile());
    } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
    }

It only works if I use forceDeleteOnExit which deletes only the current directory after killing the jbose server. But I need to delete the directory after the client is done with the download. At time I get 'Unable to delete file:..' because it is locked by download manager.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Iman
  • 769
  • 1
  • 13
  • 51
  • So your actual first question is "How can I detect if a client fully downloaded a file"? Maybe StackOverflow has some Q/A on that. – Kukeltje Jan 26 '17 at 10:14
  • Effectively, this is the 'duplicate' http://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download. (found via https://www.google.com/search?q=jsf+detect+download+finish). Signalling the server then is just a different question (how do I call a server side method from javascript) for which StackOverflow has Q/A to. Breaking down your 'high level' problem in parts often helps getting answers to the parts and consequently to the 'whole' problem – Kukeltje Jan 26 '17 at 10:19

0 Answers0