请问在JAVA语言里怎么作到打开一个记事本? 大家好,请问在JAVA语言里怎么作到打开一个记事本?具体:当跳出一个FileDialog 时,选中一文件(TXT格式),按打开,然后就可以打开并编辑它~,谢谢大家!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以使用线程中提到的exec("notepad") 方式打开记事本程序 使用exec方法,参数为程序的路径,注意windows路径中的\要用\\表示,就是使用转义字符 exec(String)在程序中执行指定的command命令 该方法与 exec(command, null) 同效。ps 建议搂主多看一下api文档,一起学习,呵呵 Runtime.getRuntime().exec(exeString)exeString = "cmd.exe /c start " + exeFileNameexeFileName可以是任何可执行文件的文件名,要有路径 exeString = "cmd.exe /c start " + exeFileNameRuntime.getRuntime().exec(exeString) 兄弟,这样做,我试过了!可以的!import java.io.IOException;public class HelloWorld { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("HelloWorld!"); String exeName = "notepad.exe"; String fileName = " test.txt"; String exeString = "cmd.exe /c start " + exeName + fileName; try { Runtime.getRuntime().exec(exeString); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }} 问一个算法. 如果做一个网站,Ip在哪里申请? 如何判断ObjectOutputStream已经结束? 大家帮我看看这个java单链表的程序 求常用算法的java版 在java中,怎样使用另外一个类中的对象…………在线等 怎么就有问题呢??? java显示问题??请大家帮帮忙!!谢谢 接口是什么啊 请问有谁知道哪里有com.borland.diag.*这个包.太感谢了. 在java中怎样保存图像?分不够再加! 请问如何建立直角坐标系,并在坐标系中把所有的点用线连接起来
在程序中执行指定的command命令
该方法与 exec(command, null) 同效。ps 建议搂主多看一下api文档,
一起学习,呵呵
exeString = "cmd.exe /c start " + exeFileName
exeFileName可以是任何可执行文件的文件名,要有路径
Runtime.getRuntime().exec(exeString)
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("HelloWorld!");
String exeName = "notepad.exe";
String fileName = " test.txt";
String exeString = "cmd.exe /c start " + exeName + fileName;
try {
Runtime.getRuntime().exec(exeString);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}