当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.moveDirectory方法代码示例

本文整理汇总了Java中org.apache.commons.io.FileUtils.moveDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.moveDirectory方法的具体用法?Java FileUtils.moveDirectory怎么用?Java FileUtils.moveDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.io.FileUtils的用法示例。


在下文中一共展示了FileUtils.moveDirectory方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execution

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) {
    // TODO Validation must be done here!!! In case none has been set!
    File filesFrom = getAbsoluteFile(transformedAppFolder, transformationContext);
    File fileTo = getFileTo(transformedAppFolder, transformationContext);
    TOExecutionResult result = null;

    try {
        FileUtils.moveDirectory(filesFrom, fileTo);
        String details = String.format("Directory '%s' has been moved to '%s'", getRelativePath(transformedAppFolder, filesFrom), getRelativePath(transformedAppFolder, fileTo));
        result = TOExecutionResult.success(this, details);
    } catch (IOException e) {
        result = TOExecutionResult.error(this, e);
    }

    return result;
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:18,代码来源:MoveDirectory.java

示例2: unzipApk

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * unzip 2 apk file
 *
 * @param outPatchDir
 */
protected File unzipApk(File outPatchDir) throws IOException {
    File unzipFolder = new File(outPatchDir, "unzip");
    if (!unzipFolder.exists()){
        unzipFolder.mkdirs();
    }
    File baseApkUnzipFolder = new File(unzipFolder, BASE_APK_UNZIP_NAME);
    File newApkUnzipFolder = new File(unzipFolder, NEW_APK_UNZIP_NAME);
    CommandUtils.exec(outPatchDir,"unzip "+input.baseApkBo.getApkFile().getAbsolutePath()+" -d "+baseApkUnzipFolder.getAbsolutePath());

    if (input.newApkBo.getApkFile().isDirectory()){
        FileUtils.moveDirectory(input.newApkBo.getApkFile(), newApkUnzipFolder);
    }else {
        CommandUtils.exec(outPatchDir,"unzip "+input.newApkBo.getApkFile().getAbsolutePath()+" -d "+ newApkUnzipFolder.getAbsolutePath());
    }

    return unzipFolder;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:23,代码来源:AbstractTool.java

示例3: unzipFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private File unzipFile(File cachedFile) throws IOException {
  String filename = cachedFile.getName();
  File destDir = new File(cachedFile.getParentFile(), filename + "_unzip");
  if (!destDir.exists()) {
    File lockFile = new File(cachedFile.getParentFile(), filename + "_unzip.lock");
    FileOutputStream out = new FileOutputStream(lockFile);
    try {
      FileLock lock = out.getChannel().lock();
      try {
        // Recheck in case of concurrent processes
        if (!destDir.exists()) {
          Path tempDir = fileCache.createTempDir();
          ZipUtils.unzip(cachedFile, tempDir.toFile(), newLibFilter());
          FileUtils.moveDirectory(tempDir.toFile(), destDir);
        }
      } finally {
        lock.release();
      }
    } finally {
      out.close();
      FileUtils.deleteQuietly(lockFile);
    }
  }
  return destDir;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:26,代码来源:DefaultPluginJarExploder.java

示例4: moveDirectory

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void moveDirectory(File source, File destination) {
    try {
        FileUtils.moveDirectory(source, destination);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:GFileUtils.java

示例5: move_to_csap_saved_folder

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void move_to_csap_saved_folder ( File folder_to_backup, StringBuilder operation_output )
		throws IOException {

	File csapSavedFolder = getCsapSavedFolder();

	String now = LocalDateTime.now().format( DateTimeFormatter.ofPattern( "MMM.d-HH.mm.ss" ) );

	File backUpFolder = new File( csapSavedFolder, folder_to_backup.getName() + "." + now );

	if ( backUpFolder.exists() ) {
		logger.info( "Warning: agent jobs are not cleaning up: {}", backUpFolder.getAbsolutePath() );
		FileUtils.deleteQuietly( backUpFolder );
		operation_output.append( "\n\n Deleting previous backup: " + backUpFolder.getAbsolutePath() + "\n" );
	}

	if ( folder_to_backup.exists() ) {

		logger.info( "Moving: {} to {}", folder_to_backup.getAbsolutePath(), backUpFolder.getAbsolutePath() );

		operation_output.append( "\n\n Moving : "
				+ folder_to_backup.getAbsolutePath()
				+ " to: "
				+ backUpFolder.getAbsolutePath() + "\n" );

		FileUtils.moveDirectory( folder_to_backup, backUpFolder );
	} else {
		operation_output.append( "Folder does not exist: " + folder_to_backup.getCanonicalPath() );
		logger.warn( "Folder does not exist: {}", folder_to_backup.getCanonicalPath() );

	}
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:32,代码来源:Application.java

示例6: deleteCollection

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void deleteCollection(String collectionName) {
    try {
        File directory = new File(resolver.getCollectionPath(collectionName));
        File renamed = new File(System.getProperty("java.io.tmpdir") + "/" + collectionName);

        if(!directory.exists()) return;

        FileUtils.moveDirectory(directory, renamed);
        FileUtils.deleteDirectory(renamed);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:AntonioGabrielAndrade,项目名称:LIRE-Lab,代码行数:14,代码来源:CollectionTestHelper.java

示例7: moveFolder

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * 移动目录
 * @author Rocye
 * @param srcPath 	移动目录的源路径
 * @param destPath 	移动目录的目的路径
 * @param isMoveRoot 是否移动根目录 true 为移动根目录 false 为不移动根目录,只移动根目录下的所有文件以及文件夹
 * @return true OR false
 * @version 2017-02-28
 */
public static boolean moveFolder(String srcPath, String destPath, boolean isMoveRoot) {
	try {
		if(isMoveRoot){
			FileUtils.moveDirectoryToDirectory(new File(srcPath), new File(destPath), true);
		}else{
			FileUtils.moveDirectory(new File(srcPath), new File(destPath));
		}
		return true;
	} catch (IOException e) {
		e.printStackTrace();
		logger.error("调用ApacheCommon移动文件夹时:" + e.toString());
		return false;
	}
}
 
开发者ID:rocye,项目名称:wx-idk,代码行数:24,代码来源:FileIo.java

示例8: pushArtifactsToLocalRepo

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void pushArtifactsToLocalRepo(Plugin plugin) {
    try {

        String latestGitTag = plugin.getTag();

        Path cachePath = gitCachePath(plugin);

        // default outputs is dist folder
        Path artifactPath = Paths.get(cachePath.toString(), DIST);

        // create tmp folder to store build outputs
        Path tmp = Paths.get(gitCacheWorkspace.toString(), "tmp");
        if (!tmp.toFile().exists()) {
            Files.createDirectories(tmp);
        }

        // move artifacts to tmp folder
        Path actPath = Paths.get(tmp.toString(), DIST);
        if (actPath.toFile().exists()) {
            FileUtils.deleteDirectory(actPath.toFile());
        }
        FileUtils.moveDirectory(artifactPath.toFile(), actPath.toFile());

        Path localPath = gitRepoPath(plugin);

        // init git and push tags
        JGitUtil.init(actPath, false);
        JGitUtil.remoteSet(actPath, LOCAL_REMOTE, localPath.toString());
        Git git = Git.open(actPath.toFile());

        git.add()
            .addFilepattern(".")
            .call();

        git.commit()
            .setMessage("add build outputs")
            .call();

        git.tag()
            .setName(plugin.getTag())
            .setMessage("add " + plugin.getTag())
            .call();

        JGitUtil.push(actPath, LOCAL_REMOTE, latestGitTag);
        // set currentTag latestTag
        plugin.setCurrentTag(latestGitTag);
        updatePluginStatus(plugin, INSTALLED);

        // delete path
        FileUtils.deleteDirectory(actPath.toFile());
    } catch (Throwable e) {

    }

}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:56,代码来源:PluginServiceImpl.java

示例9: renameExistingSharedConfigDirectory

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void renameExistingSharedConfigDirectory() {
  File configDirFile = new File(configDirPath);
  if (configDirFile.exists()) {
    String configDirFileName2 = CLUSTER_CONFIG_ARTIFACTS_DIR_NAME
        + new SimpleDateFormat("yyyyMMddhhmm").format(new Date()) + "." + System.nanoTime();
    File configDirFile2 = new File(configDirFile.getParent(), configDirFileName2);
    try {
      FileUtils.moveDirectory(configDirFile, configDirFile2);
    } catch (IOException e) {
      logger.info(e);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:14,代码来源:ClusterConfigurationService.java

示例10: prepare

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
protected ManagedJvmBuilder prepare() {
    final String backupExtension = "." + System.currentTimeMillis();
    if (getStagingDir().exists()) {
        try {
            File backUp = new File(getStagingDir() + backupExtension);
            LOGGER.debug("Dir {} already exists. Backing it up to {}", getStagingDir().getAbsoluteFile(), backUp.getAbsoluteFile());
            FileUtils.moveDirectory(getStagingDir(), backUp);
        } catch (IOException e) {
            throw new JvmServiceException(e);
        }
    }

    return this;
}
 
开发者ID:cerner,项目名称:jwala,代码行数:15,代码来源:ManagedJvmBuilder.java

示例11: doApkBuild

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@TaskAction
public void doApkBuild() throws Exception {

    //TODO Merge 2 zip packages
    apkFile = getApkFile();
    diffAPkFile = getDiffAPkFile();

    Profiler.start("build tpatch apk");

    Profiler.enter("prepare dir");
    File tmpWorkDir = new File(diffAPkFile.getParentFile(), "tmp-apk");
    if (tmpWorkDir.exists()) {
        FileUtils.deleteDirectory(tmpWorkDir);
    }
    if (!tmpWorkDir.exists()) {
        tmpWorkDir.mkdirs();
    }

    BetterZip.unzipDirectory(apkFile,tmpWorkDir);

    //Map zipEntityMap = new HashMap();
    //ZipUtils.unzip(apkFile, tmpWorkDir.getAbsolutePath(), "UTF-8", zipEntityMap, true);

    FileUtils.deleteDirectory(new File(tmpWorkDir, "assets"));
    FileUtils.deleteDirectory(new File(tmpWorkDir, "res"));
    FileUtils.forceDelete(new File(tmpWorkDir, "resources.arsc"));
    FileUtils.forceDelete(new File(tmpWorkDir, "AndroidManifest.xml"));

    File resdir = new File(diffAPkFile.getParentFile(), "tmp-diffResAp");
    resdir.mkdirs();
    ZipUtils.unzip(getResourceFile(), resdir.getAbsolutePath(), "UTF-8", new HashMap<String, ZipEntry>(), true);

    FileUtils.copyDirectory(resdir, tmpWorkDir);

    Profiler.release();

    Profiler.enter("rezip");

    if (getProject().hasProperty("atlas.createDiffApk")) {
        BetterZip.zipDirectory(tmpWorkDir, diffAPkFile);
    }else {
        FileUtils.moveDirectory(tmpWorkDir,diffAPkFile);
    }

    //ZipUtils.rezip(diffAPkFile, tmpWorkDir, zipEntityMap);
    Profiler.release();

    FileUtils.deleteDirectory(tmpWorkDir);
    FileUtils.deleteDirectory(resdir);

    getLogger().warn(Profiler.dump());

}
 
开发者ID:alibaba,项目名称:atlas,代码行数:54,代码来源:TPatchDiffApkBuildTask.java

示例12: doActionForSourceDirectory

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
protected void doActionForSourceDirectory(File sourceFile, File destinationFile) throws IOException {
	FileUtils.moveDirectory(sourceFile, destinationFile);
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:5,代码来源:MoveStep.java


注:本文中的org.apache.commons.io.FileUtils.moveDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。