总要有一个开始吧

群里面有一个哥们,问这个问题,索性记录下来,

quextion: Java怎么把一个.log文件,以text文件方式打开,显示在桌面

anwser: 这里注意一个问题;拼接路径的时候必须要注意,加一个空格 不然是抛出异常的

public class C{

public static void main(String[] args) throws IOException {
Runtime runtime = Runtime.getRuntime();
Process exec = runtime.exec("notepad"+" z:/A.txt");
System.out.println(exec.getOutputStream().toString());
}
}

扩展

其他可能会用到的命令

notepad

mstsc

mspaint