1 3 package jodd.io; 4 5 import java.io.File ; 6 import java.io.IOException ; 7 import java.net.URI ; 8 9 12 public class FileEx extends File { 13 14 16 public FileEx(String pathname) { 17 super(pathname); 18 } 19 20 public FileEx(String parent, String child) { 21 super(parent, child); 22 } 23 24 public FileEx(File parent, String child) { 25 super(parent, child); 26 } 27 28 public FileEx(URI uri) { 29 super(uri); 30 } 31 32 33 35 protected FileUtil.Settings settings = FileUtil.cloneSettings(); 36 37 public void setPreserveDate(boolean value) { 38 settings.preserveDate = value; 39 } 40 public boolean isPreserveDate() { 41 return settings.preserveDate; 42 } 43 44 public void setOverwriteExisting(boolean value) { 45 settings.overwriteExisting = value; 46 } 47 public boolean isOverwriteExisting() { 48 return settings.overwriteExisting; 49 } 50 51 public void setCreateDirs(boolean value) { 52 settings.createDirs = value; 53 } 54 public boolean isCreateDirs() { 55 return settings.createDirs; 56 } 57 58 public void setRecursive(boolean value) { 59 settings.recursive = value; 60 } 61 public boolean isRecursive() { 62 return settings.recursive; 63 } 64 65 public boolean isContinueOnError() { 66 return settings.continueOnError; 67 } 68 public void setContinueOnError(boolean continueOnError) { 69 settings.continueOnError = continueOnError; 70 } 71 72 public String getEncoding() { 73 return settings.encoding; 74 } 75 public void setEncoding(String encoding) { 76 settings.encoding = encoding; 77 } 78 79 81 public void touch() throws IOException { 82 FileUtil.touch(this); 83 } 84 85 public void copyFile(File dest) throws IOException { 86 FileUtil.copyFile(this, dest, settings); 87 } 88 public void copyToDir(File dest) throws IOException { 89 FileUtil.copyFileToDir(this, dest, settings); 90 } 91 public void copyDir(File dest) throws IOException { 92 FileUtil.copyDir(this, dest, settings); 93 } 94 95 public void moveFile(File dest) throws IOException { 96 FileUtil.moveFile(this, dest, settings); 97 } 98 public void moveToDir(File dest) throws IOException { 99 FileUtil.moveFileToDir(this, dest, settings); 100 } 101 public void moveDir(File dest) throws IOException { 102 FileUtil.moveDir(this, dest); 103 } 104 105 public void deleteFile() throws IOException { 106 FileUtil.deleteFile(this); 107 } 108 public void deleteDir() throws IOException { 109 FileUtil.deleteDir(this, settings); 110 } 111 public void cleanDir() throws IOException { 112 FileUtil.cleanDir(this, settings); 113 } 114 115 public String readString() throws IOException { 116 return FileUtil.readString(this); 117 } 118 public String readString(String encoding) throws IOException { 119 return FileUtil.readString(this, encoding); 120 } 121 public void writeString(String data) throws IOException { 122 FileUtil.writeString(this, data); 123 } 124 public void writeString(String data, String encoding) throws IOException { 125 FileUtil.writeString(this, data, encoding); 126 } 127 128 public byte[] readBytes() throws IOException { 129 return FileUtil.readBytes(this); 130 } 131 public void writeBytes(byte[] data) throws IOException { 132 FileUtil.writeBytes(this, data); 133 } 134 135 public boolean compare(File dest) throws IOException { 136 return FileUtil.compare(this, dest); 137 } 138 139 public boolean isNewer(File reference) { 140 return FileUtil.isNewer(this, reference); 141 } 142 public boolean isNewer(long timeMillis) { 143 return FileUtil.isNewer(this, timeMillis); 144 } 145 public boolean isOlder(File reference) { 146 return FileUtil.isOlder(this, reference); 147 } 148 public boolean isOlder(long timeMillis) { 149 return FileUtil.isOlder(this, timeMillis); 150 } 151 152 153 public void copy(File dest) throws IOException { 154 FileUtil.copy(this, dest, settings); 155 } 156 public void move(File dest) throws IOException { 157 FileUtil.move(this, dest, settings); 158 } 159 public void delete(File dest) throws IOException { 160 FileUtil.delete(this, settings); 161 } 162 163 } 164 | Popular Tags |