如何在java中打开记事本文件? [英] How to open the notepad file in java?
本文介绍了如何在java中打开记事本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的Java程序中打开记事本。假设我有一个按钮,如果单击此按钮,将出现记事本。
我已经有了文件名和目录。
I want to open Notepad in my Java program. Suppose that I have one button if I click this button the notepad will appear. I already have a file name and a directory.
如何实施此案例?
推荐答案
尝试
if (Desktop.isDesktopSupported()) {
Desktop.getDesktop().edit(file);
} else {
// dunno, up to you to handle this
}
确保文件存在。感谢Andreas_D指出了这一点。
Make sure the file exists. Thanks to Andreas_D who pointed this out.
这篇关于如何在java中打开记事本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文