Create some temp files, ls them, and rm them : UNIX Win32 « Development Class « Java






Create some temp files, ls them, and rm them

  
import java.io.*;

/*
 * create some temp files, ls them, and rm them
 */
public class ExecDemoRm {
  public static void main(String[] args) throws IOException {
    for (int i=0; i<10; i++) {
      new File("/tmp/ww" + i).createNewFile();
    }
    Runtime.getRuntime().exec("ls -l /tmp/ww? > /tmp/report");
    Runtime.getRuntime().exec("rm -f /tmp/ww?");
  }
}



           
         
    
  








Related examples in the same category

1.Java 1.5 (5.0) Changes to the API: ProcessBuilder.
2.How to execute a program from within Java
3.How to execute an external program How to execute an external program
4.Show how to use exec to pass complex args
5.ExecDemo shows how to execute an external program 2
6.ExecDemo shows how to execute an external program
7.Execute an external program read its output, and print its exit status
8.ExecDemoHelp shows how to use the Win32 start command
9.ExecDemo shows how to execute an external program and read its output
10.ExecDemo shows how to execute an external program and read its output 3
11.UNIX getopt() system call
12.Unix Crypt
13.Handles program arguments like Unix getopt()
14.Helper method to execute shell command
15.dealing with Excel dates