I am having a problem.
I have a function to remove some files and then reboot the system. It contains a lot of files, so before the whole set of files are getting deleted, my reboot command is getting executed.
How can I solve this in my Java code.
To delete the files, I am using:
Runtime.exec("/bin/rm -rf /myDir");
Runtime.exec("/bin/shutdown -r now");
You can use the
Processreturned byexecand wait until it finishes: