The whole processing takes several minutes, and it's happened that the
program exited because I hit on ctrl+c. What I want in this case is
that before exiting the program saves what it's done so far. So the
next time I won't have to start from a scratch.
I wrote this little example to show how I solved the problem.
http://www.wikijava.org/wiki/Controlling_the_closure_of_a_program
Enjoy,
Giulio