Wildcard Deletion throughJava out-of-process
Posted on 2002-03-04
I'm running JDK 1.3 under Unix environment. If I want to delete all .pdf files in a directory, I can do so on the command line by just typing "rm *.pdf". But I'm having problems doing this through Java, such as the following:
String commandString = "rm *.pdf";
Process p = Runtime.getRuntime().exec(commandString);
catch (Exception e)
If I specify a file exactly (like a.pdf), it does delete that specific file. But if I use the wildcard (*), nothing happens. How can I delete using wildcard? Thanks in advance.