1 package org.oddjob.io; 2 3 import java.io.File ; 4 import java.io.IOException ; 5 import java.io.Serializable ; 6 7 import org.apache.commons.io.FileUtils; 8 9 24 25 public class MkdirJob implements Runnable , Serializable { 26 private static final long serialVersionUID = 20060117; 27 28 33 private String name; 34 35 40 private File dir; 41 42 47 public String getName() { 48 return name; 49 } 50 51 56 public void setName(String name) { 57 this.name = name; 58 } 59 60 65 public File getDir() { 66 return dir; 67 } 68 69 74 public void setDir(File file) { 75 this.dir = file; 76 } 77 78 82 public void run() { 83 if (dir == null) { 84 throw new IllegalStateException ("File must be specified."); 85 } 86 try { 87 FileUtils.forceMkdir(dir); 88 } catch (IOException e) { 89 throw new RuntimeException (e); 90 } 91 } 92 93 97 public String toString() { 98 if (name ==null) { 99 return "Create a Directory"; 100 } 101 return name; 102 } 103 } 104 | Popular Tags |