本文整理了Java中org.apache.openejb.loader.IO.doCopyDirectory()
方法的一些代码示例,展示了IO.doCopyDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IO.doCopyDirectory()
方法的具体详情如下:
包路径:org.apache.openejb.loader.IO
类名称:IO
方法名:doCopyDirectory
暂无
代码示例来源:origin: org.apache.openejb/openejb-loader
public static void copyDirectory(final File srcDir, final File destDir) throws IOException {
if (srcDir == null) {
throw new NullPointerException("Source must not be null");
}
if (destDir == null) {
throw new NullPointerException("Destination must not be null");
}
if (!srcDir.exists()) {
throw new FileNotFoundException("Source '" + srcDir + "' does not exist");
}
if (!srcDir.isDirectory()) {
throw new IOException("Source '" + srcDir + "' exists but is not a directory");
}
if (srcDir.getCanonicalPath().equals(destDir.getCanonicalPath())) {
throw new IOException("Source '" + srcDir + "' and destination '" + destDir + "' are the same");
}
// Cater for destination being directory within the source directory (see IO-141)
List<String> exclusionList = null;
if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) {
final File[] srcFiles = srcDir.listFiles();
if (srcFiles != null && srcFiles.length > 0) {
exclusionList = new ArrayList<String>(srcFiles.length);
for (final File srcFile : srcFiles) {
final File copiedFile = new File(destDir, srcFile.getName());
exclusionList.add(copiedFile.getCanonicalPath());
}
}
}
doCopyDirectory(srcDir, destDir, exclusionList);
}
代码示例来源:origin: org.apache.tomee/openejb-loader
public static void copyDirectory(final File srcDir, final File destDir) throws IOException {
if (srcDir == null) {
throw new NullPointerException("Source must not be null");
}
if (destDir == null) {
throw new NullPointerException("Destination must not be null");
}
if (!srcDir.exists()) {
throw new FileNotFoundException("Source '" + srcDir + "' does not exist");
}
if (!srcDir.isDirectory()) {
throw new IOException("Source '" + srcDir + "' exists but is not a directory");
}
if (srcDir.getCanonicalPath().equals(destDir.getCanonicalPath())) {
throw new IOException("Source '" + srcDir + "' and destination '" + destDir + "' are the same");
}
// Cater for destination being directory within the source directory (see IO-141)
List<String> exclusionList = null;
if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) {
final File[] srcFiles = srcDir.listFiles();
if (srcFiles != null && srcFiles.length > 0) {
exclusionList = new ArrayList<String>(srcFiles.length);
for (final File srcFile : srcFiles) {
final File copiedFile = new File(destDir, srcFile.getName());
exclusionList.add(copiedFile.getCanonicalPath());
}
}
}
doCopyDirectory(srcDir, destDir, exclusionList);
}
代码示例来源:origin: org.apache.openejb/openejb-loader
private static void doCopyDirectory(final File srcDir, final File destDir, final List<String> exclusionList) throws IOException {
final File[] files = srcDir.listFiles();
if (files == null) { // null if security restricted
throw new IOException("Failed to list contents of " + srcDir);
}
if (destDir.exists()) {
if (!destDir.isDirectory()) {
throw new IOException("Destination '" + destDir + "' exists but is not a directory");
}
} else {
if (!destDir.mkdirs()) {
throw new IOException("Destination '" + destDir + "' directory cannot be created");
}
}
if (!destDir.canWrite()) {
throw new IOException("Destination '" + destDir + "' cannot be written to");
}
for (final File file : files) {
final File copiedFile = new File(destDir, file.getName());
if (exclusionList == null || !exclusionList.contains(file.getCanonicalPath())) {
if (file.isDirectory()) {
doCopyDirectory(file, copiedFile, exclusionList);
} else {
copy(file, copiedFile);
}
}
}
}
代码示例来源:origin: org.apache.tomee/openejb-loader
private static void doCopyDirectory(final File srcDir, final File destDir, final List<String> exclusionList) throws IOException {
final File[] files = srcDir.listFiles();
if (files == null) { // null if security restricted
throw new IOException("Failed to list contents of " + srcDir);
}
if (destDir.exists()) {
if (!destDir.isDirectory()) {
throw new IOException("Destination '" + destDir + "' exists but is not a directory");
}
} else {
if (!destDir.mkdirs()) {
throw new IOException("Destination '" + destDir + "' directory cannot be created");
}
}
if (!destDir.canWrite()) {
throw new IOException("Destination '" + destDir + "' cannot be written to");
}
for (final File file : files) {
final File copiedFile = new File(destDir, file.getName());
if (exclusionList == null || !exclusionList.contains(file.getCanonicalPath())) {
if (file.isDirectory()) {
doCopyDirectory(file, copiedFile, exclusionList);
} else {
copy(file, copiedFile);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!