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

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

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

Utils.listDirectFiles介绍

[英]Finds all the files directly contained in a directory and with a given extension.

Search is case-insensitive. It means searching for properties or PROPERTIES extensions will give the same result.
[中]查找目录中直接包含且具有给定扩展名的所有文件。
搜索不区分大小写。这意味着搜索属性或属性扩展将得到相同的结果。

代码示例

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

componentToTargetIds.put( entry.getKey(), targetIds );
for( File f : Utils.listDirectFiles( entry.getValue(), Constants.FILE_EXT_PROPERTIES )) {
  this.logger.fine( "Registering target " + f.getName() + " from component " + entry.getKey() + " in application template " + tpl );
  String targetId;

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

/**
 * Parses a directory with one or several properties files.
 * @param directory an existing directory
 * @return a non-null list of errors
 */
public static List<ModelError> parseDirectory( File directory, Component c ) {
  // Validate all the properties
  List<ModelError> result = new ArrayList<> ();
  Set<String> targetIds = new HashSet<> ();
  for( File f : Utils.listDirectFiles( directory, Constants.FILE_EXT_PROPERTIES )) {
    TargetValidator tv = new TargetValidator( f, c );
    tv.validate();
    result.addAll( tv.getErrors());
    String id = tv.getProperties().getProperty( Constants.TARGET_PROPERTY_ID );
    if( targetIds.contains( id ))
      result.add( new ModelError( ErrorCode.REC_TARGET_CONFLICTING_ID, tv.modelObject, name( id )));
    targetIds.add( id );
  }
  // There should be properties files
  if( targetIds.isEmpty())
    result.add( new ModelError( ErrorCode.REC_TARGET_NO_PROPERTIES, null, directory( directory )));
  return result;
}

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

@Test
public void testListDirectFiles_withFileExtension() throws Exception {
  File dir = this.folder.newFolder();
  Assert.assertTrue( new File( dir, "sub" ).mkdir());
  Assert.assertTrue( new File( dir, "f1.txt" ).createNewFile());
  Assert.assertTrue( new File( dir, "sub/f2.jpg" ).createNewFile());
  Assert.assertTrue( new File( dir, "f3.txt" ).createNewFile());
  Assert.assertTrue( new File( dir, "f4.JPG" ).createNewFile());
  Assert.assertTrue( new File( dir, "sub/f5.zip" ).createNewFile());
  Assert.assertEquals( 1, Utils.listDirectFiles( dir, "jpg" ).size());
  Assert.assertEquals( 1, Utils.listDirectFiles( dir, ".jpg" ).size());
  Assert.assertEquals( 1, Utils.listDirectFiles( dir, "jPg" ).size());
  Assert.assertEquals( 2, Utils.listDirectFiles( dir, "txt" ).size());
  Assert.assertEquals( 0, Utils.listDirectFiles( dir, ".zip" ).size());
  Assert.assertEquals( 3, Utils.listDirectFiles( dir, null ).size());
  Assert.assertEquals( 0, Utils.listDirectFiles( this.folder.newFile(), null ).size());
}

相关文章