someone do it in a "rather" complex way, but works as you want...
check in this link java - How to save file using JFileChooser? - Stack Overflow