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


Java Files.move方法代码示例

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


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

示例1: close

import com.google.common.io.Files; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
    writer.close();
    if (workFile.exists()) {
        Files.move(workFile, resultFile);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:CSVResultProcessor.java

示例2: moveToInstall

import com.google.common.io.Files; //导入方法依赖的package包/类
private void moveToInstall(File source, String destination) throws IOException
{
	Path installPath = config.getInstallDir().toPath();
	Path fullDest = installPath.resolve(destination);
	ajax.addBasic(ajaxId, "Copying: " + source.getPath() + " to: " + fullDest);
	FileUtils.delete(fullDest.toFile());
	Files.createParentDirs(fullDest.toFile());
	Files.move(source, fullDest.toFile());
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:Deployer.java

示例3: upload

import com.google.common.io.Files; //导入方法依赖的package包/类
public void upload(HttpExchange exchange) throws IOException
{
	final Map<String, Pair<String, File>> streams = getMultipartStreams(exchange);
	final Pair<String, File> file = streams.get("file"); //$NON-NLS-1$
	if( file != null )
	{
		String filename = file.getFirst();
		if( Utils.VERSION_EXTRACT.matcher(filename).matches() )
		{
			File vf = config.getUpdatesDir();
			Files.move(file.getSecond(), new File(vf, filename));
		}
	}
	HttpExchangeUtils.respondRedirect(exchange, "/pages/"); //$NON-NLS-1$
}
 
开发者ID:equella,项目名称:Equella,代码行数:16,代码来源:UploadHandler.java

示例4: testRename

import com.google.common.io.Files; //导入方法依赖的package包/类
public void testRename() throws IOException, FileNotFoundException
{
	File testContent = new File(srcFolder, "tmp1");
	PrintWriter pw = new PrintWriter(testContent);
	pw.append("This is my file");
	pw.append("It has 3 lines");
	pw.append("So there");
	pw.close();

	destFolder = new File(tempFolder, "dest");
	Files.move(srcFolder, destFolder);
}
 
开发者ID:equella,项目名称:Equella,代码行数:13,代码来源:FileUtilsTest.java

示例5: move

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * Move the specified file to the specified location.
 *
 * @param from The original file
 * @param to The destination file for the output
 */
public static void move(File from, File to) {
    try {
        Files.move(from, to);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:DianoxDragon,项目名称:UltimateSpawn,代码行数:14,代码来源:FileUtils.java

示例6: process

import com.google.common.io.Files; //导入方法依赖的package包/类
@Override
public IMediaDetails process(IMediaDetails details) {
    if (!this.enabled)
        return details;

    String formatString = getNameFormatForMediaFile(details);
    File originalFile = details.getMediaFile();
    File destinationFile = generateDestinationFilename(details, formatString);
    if (destinationFile == null)
        return null;

    if (destinationFile.isDirectory())
        throw new InvalidPathException(destinationFile.getAbsolutePath(), "Destination is a directory");

    if (!ensureDirectoryExists(destinationFile))
        throw new InvalidPathException(destinationFile.getAbsolutePath(), "Cannot create destination parent directory");

    if (destinationFile.exists()) {
        if (this.skipDuplicateFiles)
            throw new InvalidPathException(destinationFile.getAbsolutePath(), "Destination already exists");
        else {
            logger.info("File has already been recorded and processed, skipping...");
            return null;
        }
    }

    try {
        Files.move(originalFile, destinationFile);
        logger.info("Moved.");
    } catch (IOException ioe) {
        logger.error(ioe.getMessage());
    }
    return details;
}
 
开发者ID:KKDad,项目名称:MediaTool,代码行数:35,代码来源:RenameMedia.java

示例7: move

import com.google.common.io.Files; //导入方法依赖的package包/类
private void move(IMediaDetails details)
{
    if (!details.getMediaFile().delete())
        return;

    try {
        File f = new File(finalFilename(details.getMediaFile().getAbsolutePath()));
        logger.info("Moving {}", f.getAbsolutePath());
        logger.info("    to {}", details.getMediaFile().getAbsolutePath());
        Files.move(f, details.getMediaFile());
        logger.info("Moved.");
    } catch (IOException ioe) {
        logger.error(ioe.getMessage());
    }
}
 
开发者ID:KKDad,项目名称:MediaTool,代码行数:16,代码来源:RemoveCommercials.java

示例8: moveFile

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * 文件移动/重命名.
 */
public static void moveFile(@NotNull File from, @NotNull File to) throws IOException {
	Validate.isTrue(isFileExists(from), from + " is not exist or not a file");
	Validate.notNull(to);
	Validate.isTrue(!isDirExists(to), to + " is  exist but it is a dir");

	Files.move(from, to);
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:11,代码来源:FileUtil.java


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