import java.io.File;class FindDesktoponWindows { public static void main(String[] args) throws Exception { if (System.getProperty("os.name").toLowerCase().indexOf("win")<0) { System.err.println("Sorry, Windows only!"); System.exit(1); } File desktopDir = new File(System.getProperty("user.home"), "Desktop"); System.out.println(desktopDir.getPath() + " " + desktopDir.exists()); java.awt.Desktop.getDesktop().open(desktopDir); }}我忘记了其他语言环境。 非常脆弱的代码 (即使对于特定于操作系统的代码也是如此)。请参阅下面的我的评论。OS X /
JFileChooser。
(System.getProperty("user.home"), "Desktop").. 如何运作..Oracle可以为此类事情提供文档。
请参阅
System.getProperty(String)&
newFile(String,String)。
我会请一位专家(或一位用户),但我认为OS
X不直接在..start屏幕上支持任何应用程序图标或文档图标,无论是默认外观,还是任何其他形式。用户
JFileChooser指向
user.home并要求他们将文档保存到桌面(或他们希望的任何位置)。



