本文整理了Java中org.neo4j.io.fs.FileUtils.moveFile()
方法的一些代码示例,展示了FileUtils.moveFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.moveFile()
方法的具体详情如下:
包路径:org.neo4j.io.fs.FileUtils
类名称:FileUtils
方法名:moveFile
[英]Utility method that moves a file from its current location to the new target location. If rename fails (for example if the target is another disk) a copy/delete will be performed instead. This is not a rename, use #renameFile(File,File,CopyOption...) instead.
[中]将文件从当前位置移动到新目标位置的实用方法。如果重命名失败(例如,如果目标是另一个磁盘),将执行复制/删除。这不是重命名,请使用#重命名文件(文件、文件、复制选项…)相反
代码示例来源:origin: neo4j/neo4j
/**
* Utility method that moves a file from its current location to the
* provided target directory. If rename fails (for example if the target is
* another disk) a copy/delete will be performed instead. This is not a rename,
* use {@link #renameFile(File, File, CopyOption...)} instead.
*
* @param toMove The File object to move.
* @param targetDirectory the destination directory
* @return the new file, null iff the move was unsuccessful
* @throws IOException
*/
public static File moveFileToDirectory( File toMove, File targetDirectory ) throws IOException
{
if ( !targetDirectory.isDirectory() )
{
throw new IllegalArgumentException(
"Move target must be a directory, not " + targetDirectory );
}
File target = new File( targetDirectory, toMove.getName() );
moveFile( toMove, target );
return target;
}
代码示例来源:origin: neo4j/neo4j
@Test
public void moveFile() throws Exception
{
File file = touchFile( "source" );
File targetDir = directory( "dir" );
File newLocationOfFile = new File( targetDir, "new-name" );
FileUtils.moveFile( file, newLocationOfFile );
assertTrue( newLocationOfFile.exists() );
assertFalse( file.exists() );
assertEquals( newLocationOfFile, targetDir.listFiles()[0] );
}
代码示例来源:origin: org.neo4j/neo4j-io
/**
* Utility method that moves a file from its current location to the
* provided target directory. If rename fails (for example if the target is
* another disk) a copy/delete will be performed instead. This is not a rename,
* use {@link #renameFile(File, File, CopyOption...)} instead.
*
* @param toMove The File object to move.
* @param targetDirectory the destination directory
* @return the new file, null iff the move was unsuccessful
* @throws IOException
*/
public static File moveFileToDirectory( File toMove, File targetDirectory ) throws IOException
{
if ( !targetDirectory.isDirectory() )
{
throw new IllegalArgumentException(
"Move target must be a directory, not " + targetDirectory );
}
File target = new File( targetDirectory, toMove.getName() );
moveFile( toMove, target );
return target;
}
内容来源于网络,如有侵权,请联系作者删除!