| | |
| | | } |
| | | |
| | | public String copyFiles(String fromPath, String toPath, List fileNames) { |
| | | String result = null; |
| | | try { |
| | | File srcDir = getTargetDir(fromPath); |
| | | File targetDir = getTargetDir(toPath); |
| | | Iterator i = fileNames.iterator(); |
| | | while(i.hasNext()) { |
| | | Object o = i.next(); |
| | | if (o instanceof ArrayList) { |
| | | ArrayList al = (ArrayList) o; |
| | | File srcFile = new File(srcDir, al.get(0).toString()); |
| | | if(srcFile.isDirectory()) { |
| | | logger.fine("copy dir " + srcFile.getAbsolutePath() + " to dir " + targetDir.getAbsolutePath()); |
| | | FileUtils.copyDirectoryToDirectory(srcFile, targetDir); |
| | | } else { |
| | | logger.fine("copy srcFile " + srcFile.getAbsolutePath() + " to dir " + targetDir.getAbsolutePath()); |
| | | FileUtils.copyFileToDirectory(srcFile, targetDir); |
| | | } |
| | | } |
| | | } |
| | | } catch (IOException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } |
| | | return result; |
| | | return copyOrMoveFiles(fromPath, toPath, fileNames, OP_COPY); |
| | | } |
| | | |
| | | public String moveFiles(String fromPath, String toPath, List fileNames) { |
| | | return copyOrMoveFiles(fromPath, toPath, fileNames, OP_MOVE); |
| | | } |
| | | |
| | | private String copyOrMoveFiles(String fromPath, String toPath, List fileNames, int operation) { |
| | | String result = null; |
| | | try { |
| | | File srcDir = getTargetDir(fromPath); |
| | |
| | | ArrayList al = (ArrayList) o; |
| | | File srcFile = new File(srcDir, al.get(0).toString()); |
| | | if(srcFile.isDirectory()) { |
| | | FileUtils.moveDirectoryToDirectory(srcFile, targetDir, false); |
| | | if(operation == OP_MOVE) { |
| | | FileUtils.moveDirectoryToDirectory(srcFile, targetDir, false); |
| | | } else { |
| | | FileUtils.copyDirectoryToDirectory(srcFile, targetDir); |
| | | } |
| | | } else { |
| | | FileUtils.moveFileToDirectory(srcFile, targetDir, false); |
| | | if(operation == OP_MOVE) { |
| | | FileUtils.moveFileToDirectory(srcFile, targetDir, false); |
| | | } else { |
| | | FileUtils.copyFileToDirectory(srcFile, targetDir); |
| | | } |
| | | } |
| | | } |
| | | } |