net.roboconf.core.utils.Utils.copyDirectory()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中net.roboconf.core.utils.Utils.copyDirectory()方法的一些代码示例,展示了Utils.copyDirectory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.copyDirectory()方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称:Utils
方法名:copyDirectory

Utils.copyDirectory介绍

[英]Copies a directory.

This method copies the content of the source directory into the a target directory. This latter is created if necessary.
[中]复制一个目录。
此方法将源目录的内容复制到目标目录中。如有必要,可创建后者。

代码示例

代码示例来源:origin: net.roboconf/roboconf-dm

Utils.copyDirectory( dir, newDir );

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testCopyDirectory_inexistingTarget() throws Exception {
  // Create a source
  File source = this.folder.newFolder();
  File dir1 = new File( source, "lol/whatever/sub/many/more/" );
  Assert.assertTrue( dir1.mkdirs());
  File dir2 = new File( source, "sub" );
  Assert.assertTrue( dir2.mkdirs());
  Utils.copyStream( new ByteArrayInputStream( ",kklmsdff sdfl sdfkkl".getBytes( "UTF-8" )), new File( dir1, "f1" ));
  Utils.copyStream( new ByteArrayInputStream( "".getBytes( "UTF-8" )), new File( dir1, "f2" ));
  Utils.copyStream( new ByteArrayInputStream( "sd".getBytes( "UTF-8" )), new File( dir1, "f3" ));
  Utils.copyStream( new ByteArrayInputStream( "sd\ndsfg".getBytes( "UTF-8" )), new File( source, "f" ));
  Utils.copyStream( new ByteArrayInputStream( "sd\ndsfg".getBytes( "UTF-8" )), new File( dir2, "f1" ));
  Utils.copyStream( new ByteArrayInputStream( "".getBytes( "UTF-8" )), new File( dir2, "f4" ));
  Utils.copyStream( new ByteArrayInputStream( "sdf df fg".getBytes( "UTF-8" )), new File( dir2, "f45678" ));
  // Copy
  File target = new File( this.folder.newFolder(), "some" );
  Assert.assertFalse( target.exists());
  Utils.copyDirectory( source, target );
  Assert.assertTrue( target.exists());
  Assert.assertEquals( 7, Utils.listAllFiles( target ).size());
}

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testCopyDirectory_existingTarget() throws Exception {
  // Create a source
  File source = this.folder.newFolder();
  File dir1 = new File( source, "lol/whatever/sub" );
  Assert.assertTrue( dir1.mkdirs());
  File dir2 = new File( source, "sub" );
  Assert.assertTrue( dir2.mkdirs());
  Utils.copyStream( new ByteArrayInputStream( ",kklmsdff sdfl sdfkkl".getBytes( "UTF-8" )), new File( dir1, "f1" ));
  Utils.copyStream( new ByteArrayInputStream( "".getBytes( "UTF-8" )), new File( dir1, "f2" ));
  Utils.copyStream( new ByteArrayInputStream( "sd".getBytes( "UTF-8" )), new File( dir1, "f3" ));
  Utils.copyStream( new ByteArrayInputStream( "sd\ndsfg".getBytes( "UTF-8" )), new File( source, "f" ));
  Utils.copyStream( new ByteArrayInputStream( "sd\ndsfg".getBytes( "UTF-8" )), new File( dir2, "f1" ));
  Utils.copyStream( new ByteArrayInputStream( "sdf df fg".getBytes( "UTF-8" )), new File( dir2, "f45678" ));
  // Copy
  File target = this.folder.newFolder();
  Assert.assertEquals( 0, Utils.listAllFiles( target ).size());
  Utils.copyDirectory( source, target );
  Assert.assertEquals( 6, Utils.listAllFiles( target ).size());
}

代码示例来源:origin: net.roboconf/roboconf-dm

throw new IOException( "Cannot move " + applicationFilesDirectory + " in Roboconf's work directory. Already a child directory." );
else
  Utils.copyDirectory( applicationFilesDirectory, targetDirectory );

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testParsingWithInvalidCommands() throws Exception {
  // Copy the application and update a command file
  File dir = TestUtils.findApplicationDirectory( "lamp" );
  Assert.assertTrue( dir.isDirectory());
  File newDir = this.folder.newFolder();
  Utils.copyDirectory( dir, newDir );
  File commandFile = new File( newDir, Constants.PROJECT_DIR_COMMANDS + "/scale.commands" );
  Assert.assertTrue( commandFile.isFile());
  File commandFileCopy = new File( newDir, Constants.PROJECT_DIR_COMMANDS + "/scale.invalid-extension" );
  Utils.copyStream( commandFile, commandFileCopy );
  Utils.writeStringInto( "this is an invalid command", commandFile );
  // Load it and verify it contains errors
  ApplicationLoadResult alr = RuntimeModelIo.loadApplication( newDir );
  List<RoboconfError> criticalErrors = new ArrayList<> ();
  for( RoboconfError error : alr.getLoadErrors()) {
    if( error.getErrorCode().getLevel() == ErrorLevel.SEVERE )
      criticalErrors.add( error );
  }
  Assert.assertEquals( 2, criticalErrors.size());
  Assert.assertEquals( ErrorCode.CMD_UNRECOGNIZED_INSTRUCTION, criticalErrors.get( 0 ).getErrorCode());
  Assert.assertEquals( ErrorCode.PROJ_INVALID_COMMAND_EXT, criticalErrors.get( 1 ).getErrorCode());
}

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testParsingWithInvalidAutonomicRules() throws Exception {
  // Copy the application and update a command file
  File dir = TestUtils.findApplicationDirectory( "lamp" );
  Assert.assertTrue( dir.isDirectory());
  File newDir = this.folder.newFolder();
  Utils.copyDirectory( dir, newDir );
  File ruleFile = new File( newDir, Constants.PROJECT_DIR_RULES_AUTONOMIC + "/sample.drl" );
  Assert.assertTrue( ruleFile.isFile());
  File ruleFileCopy = new File( newDir, Constants.PROJECT_DIR_RULES_AUTONOMIC + "/sample.drl-invalid-extension" );
  Utils.copyStream( ruleFile, ruleFileCopy );
  String s = Utils.readFileContent( ruleFile );
  s = s.replace( "scale", "inexisting-command" );
  Utils.writeStringInto( s, ruleFile );
  // Load it and verify it contains errors
  ApplicationLoadResult alr = RuntimeModelIo.loadApplication( newDir );
  List<RoboconfError> criticalErrors = new ArrayList<> ();
  for( RoboconfError error : alr.getLoadErrors()) {
    if( error.getErrorCode().getLevel() == ErrorLevel.SEVERE )
      criticalErrors.add( error );
  }
  Assert.assertEquals( 2, criticalErrors.size());
  Assert.assertEquals( ErrorCode.RULE_UNKNOWN_COMMAND, criticalErrors.get( 0 ).getErrorCode());
  Assert.assertEquals( ErrorCode.PROJ_INVALID_RULE_EXT, criticalErrors.get( 1 ).getErrorCode());
}

代码示例来源:origin: roboconf/roboconf-platform

Utils.copyDirectory( sourceDirectory, targetDirectory );

相关文章