I want to delete a directory/file programmatically in java using org.apache.commons.exec.CommandLine
.
The directory that I am trying to delete has a space character and because of that it seems I am unable to delete that.
import org.apache.commons.exec.CommandLine
try {
CommandLine command = CommandLine.parse("rm -rf ");
File targetDir = new File(getFinalSourceDirectory());
command.addArgument(dlpath); // dlpath = "tmp/dir to rmv/OSAAT - KT"
} catch (Exception ex) {
java.util.logging.Logger.getLogger(SubversionConnector.class.getName()).log(Level.SEVERE, null, ex);
}
Though the exit status is returning 0, it is not deleting the directory "OSSAT - KT"
I tried to escape the space by \\\
or %20
, etc. but nothing worked for me.