如何打开文件没有扩展名 [英] How to open file without extension

查看:199
本文介绍了如何打开文件没有扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试打开文件没有扩展名。当我尝试打开没有扩展名的文件时,系统显示打开窗体。但是,当我试图打开该文件在我的应用程序使用方法:

 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆