您的位置:首页 > 编程语言 > Java开发

Java Desktop文件操作示例

2014-05-28 23:26 274 查看
以系统默认方式打开某文件

public static void desktopTest() throws IOException {
if (!Desktop.isDesktopSupported()) {
System.out.println("Desktop not supported.");
return;
}

Desktop desktop = Desktop.getDesktop();
File file = new File("D:\\test");
if (file.exists()) {
desktop.open(file);
System.out.println("Done");
} else {
System.out.println("File not exist.");
}
}


Desktop的操作还有browse,edit等,详情见API文档
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: