如何打开文件没有扩展名 [英] How to open file without extension
本文介绍了如何打开文件没有扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private static void openFile(String fileName)throws IOException {
if(Desktop.isDesktopSupported()){
Desktop desktop = Desktop.getDesktop();
档案档案=新档案(档案名称);
desktop.open(file);
} else {
Runtime.getRuntime()。exec(String.format(cmd / c start%s,fileName));
$ b系统不显示这种形式。
如何解决这个问题?解决方案Desktop.open()启动与文件扩展名关联的应用程序。I would like to try open file without extension. When I try to open file without extension, then system show me "Open with" form. But when I am trying to open that file in side my application using method:
private static void openFile(String fileName) throws IOException { if(Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); File file = new File(fileName); desktop.open(file); } else { Runtime.getRuntime().exec(String.format("cmd /c start %s", fileName)); } }
system don't show this form. How to solve this?
解决方案Desktop.open() launches the application associated with the extension of the file.
这篇关于如何打开文件没有扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文