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


Java FileUtils.moveFile方法代码示例

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


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

示例1: moveOutput

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public boolean moveOutput() {
	File outputFile = null;
	File targetFile = null;
	try {
		for (int i = 0; i < outputFiles.length; ++i) {
			outputFile = outputFiles[i];
			targetFile = targetFiles[i];
			
			if (!outputFile.exists()) continue;
			String outputFileAbsolute = removeThisDir(outputFile.getAbsolutePath());
			String targetFileAbsolute = removeThisDir(targetFile.getAbsolutePath());
			if (outputFileAbsolute.equals(targetFileAbsolute)) continue;
			
			FileUtils.moveFile(outputFile, targetFile);
		}
		return true;
	} catch (Exception e) {
		fail("Failed to move " + outputFile.getAbsolutePath() + " to " + targetFile.getAbsolutePath(), e);
		return false;
	}
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:22,代码来源:NavMeshMakerStep.java

示例2: saveTmpFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private static State saveTmpFile(File tmpFile, String path) {
	State state = null;
	File targetFile = new File(path);

	if (targetFile.canWrite()) {
		return new BaseState(false, AppInfo.PERMISSION_DENIED);
	}
	try {
		FileUtils.moveFile(tmpFile, targetFile);
	} catch (IOException e) {
		return new BaseState(false, AppInfo.IO_ERROR);
	}

	state = new BaseState(true);
	state.putInfo("size", targetFile.length());
	state.putInfo("title", targetFile.getName());

	return state;
}
 
开发者ID:funtl,项目名称:framework,代码行数:20,代码来源:StorageManager.java

示例3: doTask

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

    baseApkFile = getBaseApkFile();
    destPath = getDestPath();
    awoFile = getAwoFile();
    zipAlign = getZipAlign();
    outApkFile = getOutApkFile();

    ZipUtils.addFileToZipFile(baseApkFile, outApkFile, awoFile, destPath, true);

    File signFile = new File(outApkFile.getParent(), outApkFile.getName().replace(".apk", "-signed.apk"));
    AtlasBuildContext.sBuilderAdapter.androidSigner.signFile(outApkFile, signFile, getSigningConfig());
    if (null != zipAlign && zipAlign) {
        File signAndZipAlignedFile = ZipAlignUtils.doZipAlign(androidBuilder, getProject(), signFile);
        FileUtils.deleteQuietly(outApkFile);
        FileUtils.moveFile(signAndZipAlignedFile, outApkFile);
    }

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

示例4: saveFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * The operation copies the file in the specified path.
 * @param dirPath Target directory
 * @param fileName File name
 * @param srcFile
 * @throws IOException
 */
public static void saveFile(String dirPath, String fileName, File srcFile)
        throws IOException {
    
    try {
        File uploadPart = new File(dirPath, fileName);
        if (uploadPart.exists()) {
            uploadPart.delete();
        }
        FileUtils.moveFile(srcFile, uploadPart);
    } catch (IOException ex) {
        String prefix = "Save file error: '";
        Logger.error(prefix + ex.getMessage() + "'");
        throw new IOException(prefix + ex.getMessage() + "'");
    }
}
 
开发者ID:webinerds,项目名称:s3-proxy-chunk-upload,代码行数:23,代码来源:IOUploadUtils.java

示例5: saveTmpFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private static State saveTmpFile(File tmpFile, String path) {
	File targetFile = new File(path);

	if (targetFile.canWrite()) {
		return new BaseState(false, AppInfo.PERMISSION_DENIED);
	}
	try {
		FileUtils.moveFile(tmpFile, targetFile);
	} catch (IOException e) {
		return new BaseState(false, AppInfo.IO_ERROR);
	}

	State state = new BaseState(true);
	state.putInfo("size", targetFile.length());
	state.putInfo("title", targetFile.getName());
	return state;
}
 
开发者ID:TomChen001,项目名称:xmanager,代码行数:18,代码来源:DefaultFileManager.java

示例6: main

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
	Thread.sleep(3000); //We wait a few seconds to allow the old instance to close so we can rename it without causing an exception
	File oldJar = new File(args[0]);
	File newJar = getTempFile(false);
	File backupJar = new File(oldJar.getAbsolutePath() + ".old");
	if (backupJar.exists()) {
		backupJar.delete();
	}
	FileUtils.moveFile(oldJar, backupJar); //Backup the old jar so if things go wrong it can be manually reverted
	FileUtils.copyFile(newJar, oldJar);

	List<String> newArgs = new ArrayList<>();
	newArgs.add("java");
	newArgs.add("-jar");
	newArgs.add(oldJar.getAbsolutePath()); //The old jar is now the new jar as we copyied it over
	newArgs.add("-updateSuccess"); //Added here so we can show a dialog if when the new jar is opened

	ProcessBuilder processBuilder = new ProcessBuilder();
	processBuilder.command(newArgs);
	processBuilder.start();
	//Should close here
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:23,代码来源:Updater.java

示例7: saveJobLog

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * save job zip
 */
private File saveJobLog(Job job) {
    Path jobPath = getJobLogPath(job);
    Path zipPath = Paths.get(jobPath.getParent().toString(), job.getId().toString() + ".zip");
    Path destPath = Paths.get(jobPath.toString(), job.getId().toString() + ".zip");
    File folderFile = new File(jobPath.toString());
    File zipFile = new File(zipPath.toString());
    File destFile = new File(destPath.toString());

    try {
        ZipUtil.zipFolder(folderFile, zipFile);
        FileUtils.moveFile(zipFile, destFile);
    } catch (IOException e) {
        throw new FlowException("save zip log error");
    }

    return destFile;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:21,代码来源:LogServiceImpl.java

示例8: moveFile

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

示例9: fix

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public synchronized boolean fix(File file) throws IOException {
	File tempFile = new File("temp.line-endings.txt");
	if (fix(file, tempFile)) {
		// file was changed
		file.delete();
		FileUtils.moveFile(tempFile, file);
		tempFile.delete();
		return true;
	} else {
		// no changes
		tempFile.delete();
		return false;
	}
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:15,代码来源:FixLineEndings.java

示例10: rewriteFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public synchronized boolean rewriteFile(File file, String encoding) throws IOException {
	File tempFile = new File("temp.rewrite.txt");
	if (rewriteFile(file, tempFile, encoding)) {
		// file was changed
		file.delete();
		FileUtils.moveFile(tempFile, file);
		tempFile.delete();
		return true;
	} else {
		// no changes
		tempFile.delete();
		return false;
	}
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:15,代码来源:Rewriter.java

示例11: moveFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void moveFile(String currentAbsolutePath, String newAbsolutePath) throws BuenOjoFileException{
	try {
		FileUtils.moveFile(new File(currentAbsolutePath), new File(newAbsolutePath));
	}  catch (FileExistsException fe){
		log.error(fe.getMessage());
		throw new BuenOjoFileException("no se pudo mover el archivo: " +currentAbsolutePath+" al destino"+ newAbsolutePath + " porque ese archivo ya existe");
	} catch (IOException e) {
		log.error(e.getMessage());
		throw new BuenOjoFileException("no se pudo mover el archivo: " +currentAbsolutePath+" al destino: "+ newAbsolutePath + e.getMessage());
	}
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:12,代码来源:ImageResourceService.java

示例12: takeFullScreenshot

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void takeFullScreenshot(WebDriver webDriver, File pngFile, By... highlights)
        throws IOException {
    final PageSnapshot pageSnapshot = Shutterbug.shootPage(webDriver, BOTH_DIRECTIONS);
    if (ArrayUtils.isNotEmpty(highlights)) {
        Arrays.stream(highlights)
                .map(webDriver::findElements)
                .flatMap(Collection::stream)
                .forEach(pageSnapshot::highlight);
    }
    FileUtils.forceMkdirParent(pngFile);
    pageSnapshot.withName(pngFile.getName());
    pageSnapshot.save(pngFile.getParent());
    FileUtils.deleteQuietly(pngFile);
    FileUtils.moveFile(new File(pngFile.getPath() + ".png"), pngFile);
}
 
开发者ID:ldaume,项目名称:headless-chrome,代码行数:16,代码来源:HeadlessDriverUtils.java

示例13: writeFileToApk

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void writeFileToApk(File destFile, File file, String path) throws IOException {
    File outPutFile = new File(file.getParent(), "temp.apk");
    ZipUtils.addFileToZipFile(file, outPutFile, destFile, path, true);
    FileUtils.deleteQuietly(file);
    FileUtils.moveFile(outPutFile, file);
    FileUtils.deleteQuietly(destFile);
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:8,代码来源:BuildHelper.java

示例14: moveFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * 移动文件
 * @author Rocye
 * @param srcPath 	移动的源文件路径
 * @param destPath 	移动的目标文件路径
 * @return true OR false
 * @version 2017-02-28
 */
public static boolean moveFile(String srcPath, String destPath) {
	try {
		FileUtils.moveFile(new File(srcPath), new File(destPath));
		return true;
	} catch (IOException e) {
		e.printStackTrace();
		logger.error("调用ApacheCommon移动文件时:" + e.toString());
		return false;
	}
}
 
开发者ID:rocye,项目名称:wx-idk,代码行数:19,代码来源:FileIo.java

示例15: backupLog

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void backupLog() {
    try {
        File bkp = new File(LOG_BKP_LOC);
        if (!bkp.exists()) {
            bkp.mkdirs();
        }
        String filename = "log-" + Utility.getdatetimeString() + ".txt";
        FileUtils.moveFile(new File(LOG_FILE), new File(bkp, filename));
    } catch (IOException ex) {
        java.util.logging.Logger.getLogger(UILogger.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:13,代码来源:UILogger.java


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