output.close() nn file... e return chooser.getSelectedFile();

ps..quando stai salvando su file metti le istruzioni in un blocco try-catch