Java tutorial
import java.io.File; import java.io.FileWriter; import java.io.IOException; import javax.swing.JFileChooser; public class Main { public static void main(String[] args) { String text = "JFileChooser, you're my only friend."; JFileChooser chooser = new JFileChooser(); int result = chooser.showSaveDialog(null); if (result == JFileChooser.APPROVE_OPTION) { try { File file = chooser.getSelectedFile(); FileWriter writer = new FileWriter(file); writer.write(text); writer.close(); } catch (IOException ex) { ex.printStackTrace(); } } } }