本文整理了Java中org.apache.maven.shared.utils.io.FileUtils.copyFileToDirectory()
方法的一些代码示例,展示了FileUtils.copyFileToDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.copyFileToDirectory()
方法的具体详情如下:
包路径:org.apache.maven.shared.utils.io.FileUtils
类名称:FileUtils
方法名:copyFileToDirectory
[英]Copy file from source to destination. If destinationDirectory
does not exist, it (and any parent directories) will be created. If a file source
in destinationDirectory
exists, it will be overwritten.
[中]将文件从源复制到目标。如果destinationDirectory
不存在,将创建它(和任何父目录)。如果destinationDirectory
中存在文件source
,则该文件将被覆盖。
代码示例来源:origin: vipshop/Saturn
private void copy(File source, File destinationDir) throws IOException {
if (source.isFile()) {
FileUtils.copyFileToDirectory(source, destinationDir);
} else if (source.isDirectory()) {
File newDestinationDir = new File(destinationDir, source.getName());
if (!newDestinationDir.exists()) {
newDestinationDir.mkdirs();
}
for (File tmp : source.listFiles()) {
copy(tmp, newDestinationDir);
}
}
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
copyFileToDirectory( file, destination );
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
/**
* Copy a directory to an other one.
*
* @param sourceDirectory the source dir
* @param destinationDirectory the target dir
* @param includes include pattern
* @param excludes exlucde pattern
* @throws IOException if any
* @see #getFiles(File, String, String)
*/
public static void copyDirectory( @Nonnull File sourceDirectory, @Nonnull File destinationDirectory,
@Nullable String includes, @Nullable String excludes )
throws IOException
{
if ( !sourceDirectory.exists() )
{
return;
}
List<File> files = getFiles( sourceDirectory, includes, excludes );
for ( File file : files )
{
copyFileToDirectory( file, destinationDirectory );
}
}
内容来源于网络,如有侵权,请联系作者删除!