Java tutorial
//package com.java2s; import java.awt.FileDialog; public class Main { /** * Returns the full path to the file, if a file was selected. * Otherwise it returns null. */ public static String getCanonicalFilenameFromFileDialog(FileDialog fileDialog) { if (fileDialog.getDirectory() == null) return null; if (fileDialog.getFile() == null) return null; // this line not needed on mac os x //return fileDialog.getDirectory() + System.getProperty("file.separator") + fileDialog.getFile(); return fileDialog.getDirectory() + fileDialog.getFile(); } }