Java examples for Swing:JFileChooser
Creating a File Chooser Dialog
import java.io.File; import javax.swing.JFileChooser; import javax.swing.JFrame; public class Main { public static void main(String[] args) { String filename = File.separator + "tmp"; JFileChooser fc = new JFileChooser(new File(filename)); JFrame frame = null;/*from w w w. java 2 s .c o m*/ // Open file dialog. fc.showOpenDialog(frame); // Save file dialog. fc.showSaveDialog(frame); } }