本文整理汇总了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);
}
}
示例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());
}
示例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$
}
示例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);
}
示例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();
}
}
示例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;
}
示例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());
}
}
示例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);
}