Copy a folder from one place to another. This ignores all dot files and folders found in the source directory, to avoid copying silly .DS_Store files and potentially troublesome .svn folders.
(File sourceDir,
File targetDir)
| 234 | * files and potentially troublesome .svn folders. |
| 235 | */ |
| 236 | static public void copyDir(File sourceDir, |
| 237 | File targetDir) throws IOException { |
| 238 | if (sourceDir.equals(targetDir)) { |
| 239 | final String urDum = "source and target directories are identical"; |
| 240 | throw new IllegalArgumentException(urDum); |
| 241 | } |
| 242 | targetDir.mkdirs(); |
| 243 | String files[] = sourceDir.list(); |
| 244 | for (int i = 0; i < files.length; i++) { |
| 245 | // Ignore dot files (.DS_Store), dot folders (.svn) while copying |
| 246 | if (files[i].charAt(0) == '.') continue; |
| 247 | //if (files[i].equals(".") || files[i].equals("..")) continue; |
| 248 | File source = new File(sourceDir, files[i]); |
| 249 | File target = new File(targetDir, files[i]); |
| 250 | if (source.isDirectory()) { |
| 251 | //target.mkdirs(); |
| 252 | copyDir(source, target); |
| 253 | target.setLastModified(source.lastModified()); |
| 254 | } else { |
| 255 | copyFile(source, target); |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | |
| 261 | static public void copyDirNative(File sourceDir, |
no test coverage detected