當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。