0

I need to clean a temp directory when the application closes. On Linux and Mac the following command is working perfectly:

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);
}

What is the Windows equivalent of ' rm -f ' Linux command.

gudok
  • 4,029
  • 2
  • 20
  • 30
Charles Mosndup
  • 600
  • 6
  • 19
  • 3
    Use the built in libraries, such as `File` and/or `Path` to access files and directories. And don't use the `Runtime` – Lino Jan 09 '19 at 14:25
  • 1
    You can use `deleteOnExit();` method in `File` class. Files marked in such way will be deleted when JVM exits gracefully – Ivan Jan 09 '19 at 14:35

0 Answers0