我尝试用editor.exe打开file.txt
editor.exe是从编写在Java上的editor.jar转换而来的
我是否有能力从editor.exe的java源代码中获取file.txt绝对文件路径?
答案 0 :(得分:1)
查看您的main
方法;具体地,
public static void main(String[] args) {
// args[0] should be the path that was requested, in which case you
// could use
if (args.length > 0) {
java.io.File f = new java.io.File(args[0]);
if (f != null && f.exists()) {
try {
System.out.println(f.getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
}
}
}
}