Runtime.getRuntime()。exec(“ rm -f ./temp/*”)取决于平台

时间:2019-01-09 14:23:08

标签: java linux windows

我需要在应用程序关闭时清理一个临时目录。 在Linux和Mac上,以下命令可以正常运行:

public void windowClosing(WindowEvent e) {
  Debug.infomess("clean exit");
  try {
    Runtime.getRuntime().exec("rm -f ./temp/*");
  } catch (IOException e1) {
    Debug.errmess(e1,"Exit error");
  }
  System.exit(0);
}

Windows等效于'rm -f'Linux命令。

0 个答案:

没有答案