Search code examples
javadatabaseserializationterminate

serialize objects after you terminate program


I'm familiar with the process of serializing an object and writing it to a file, but is there a way tp dp so after the user terminates the console?


Solution

  • Yes, you could add SIGTERM handler. In java you can do it by using Runtime.addShutdownHook()