org.apache.commons.io.FilenameUtils.equalsNormalizedOnSystem()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(137)

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

FilenameUtils.equalsNormalizedOnSystem介绍

[英]Checks whether two filenames are equal after both have been normalized and using the case rules of the system.

Both filenames are first passed to #normalize(String). The check is then performed case-sensitive on Unix and case-insensitive on Windows.
[中]

代码示例

代码示例来源:origin: commons-io/commons-io

@Test
public void testEqualsNormalizedOnSystem() {
  assertTrue(FilenameUtils.equalsNormalizedOnSystem(null, null));
  assertFalse(FilenameUtils.equalsNormalizedOnSystem(null, ""));
  assertFalse(FilenameUtils.equalsNormalizedOnSystem("", null));
  assertTrue(FilenameUtils.equalsNormalizedOnSystem("", ""));
  assertTrue(FilenameUtils.equalsNormalizedOnSystem("file.txt", "file.txt"));
  assertEquals(WINDOWS, FilenameUtils.equalsNormalizedOnSystem("file.txt", "FILE.TXT"));
  assertTrue(FilenameUtils.equalsNormalizedOnSystem("a\\b\\file.txt", "a/b/file.txt"));
  assertFalse(FilenameUtils.equalsNormalizedOnSystem("a/b/", "a/b"));
}

代码示例来源:origin: pmd/pmd

public void add(File file) throws IOException {
  if (configuration.isSkipDuplicates()) {
    // TODO refactor this thing into a separate class
    String signature = file.getName() + '_' + file.length();
    if (current.contains(signature)) {
      System.err.println("Skipping " + file.getAbsolutePath()
          + " since it appears to be a duplicate file and --skip-duplicate-files is set");
      return;
    }
    current.add(signature);
  }
  if (!FilenameUtils.equalsNormalizedOnSystem(file.getAbsoluteFile().getCanonicalPath(),
      file.getAbsolutePath())) {
    System.err.println("Skipping " + file + " since it appears to be a symlink");
    return;
  }
  if (!file.exists()) {
    System.err.println("Skipping " + file + " since it doesn't exist (broken symlink?)");
    return;
  }
  SourceCode sourceCode = configuration.sourceCodeFor(file);
  add(sourceCode);
}

代码示例来源:origin: commons-io/commons-io

/**
 * Test for https://issues.apache.org/jira/browse/IO-128
 */
@Test
public void testEqualsNormalizedError_IO_128() {
  try {
    FilenameUtils.equalsNormalizedOnSystem("//file.txt", "file.txt");
    fail("Invalid normalized first file");
  } catch (final NullPointerException e) {
    // expected result
  }
  try {
    FilenameUtils.equalsNormalizedOnSystem("file.txt", "//file.txt");
    fail("Invalid normalized second file");
  } catch (final NullPointerException e) {
    // expected result
  }
  try {
    FilenameUtils.equalsNormalizedOnSystem("//file.txt", "//file.txt");
    fail("Invalid normalized both filse");
  } catch (final NullPointerException e) {
    // expected result
  }
}

代码示例来源:origin: omero/server

public boolean matches(File file) {
  return FilenameUtils.equalsNormalizedOnSystem(absPath, file
      .getAbsolutePath());
}

代码示例来源:origin: fabriciocolombo/sonar-delphi

private static boolean containsFile(List<File> dirs, File cursor) {
  for (File dir : dirs) {
   if (FilenameUtils.equalsNormalizedOnSystem(dir.getAbsolutePath(),
    cursor.getAbsolutePath())) {
    return true;
   }
  }
  return false;
 }
}

代码示例来源:origin: apache/stanbol

/**
 * Returns the ServiceReference for the {@link SolrCore} of the parsed
 * directory
 * @param directory the directory
 * @return the reference of <code>null</code> if no {@link SolrCore} for the
 * parsed directory is registered for this {@link CoreContainer}.
 */
public ServiceReference getCoreForDir(String directory){
  //solr always uses ending '/'
  if(directory.charAt(directory.length()-1) != File.separatorChar){
    directory = directory+File.separatorChar;
  }
  synchronized (registrations) {
    for(CoreRegistration reg : registrations.values()){
      ServiceReference ref = reg.getServiceReference();
      if(FilenameUtils.equalsNormalizedOnSystem(
        directory,(String)ref.getProperty(PROPERTY_CORE_DIR))){
        return ref;
      }
    }
  }
  return null;
}

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.commons.solr.core

/**
 * Returns the ServiceReference for the {@link SolrCore} of the parsed
 * directory
 * @param directory the directory
 * @return the reference of <code>null</code> if no {@link SolrCore} for the
 * parsed directory is registered for this {@link CoreContainer}.
 */
public ServiceReference getCoreForDir(String directory){
  //solr always uses ending '/'
  if(directory.charAt(directory.length()-1) != File.separatorChar){
    directory = directory+File.separatorChar;
  }
  synchronized (registrations) {
    for(CoreRegistration reg : registrations.values()){
      ServiceReference ref = reg.getServiceReference();
      if(FilenameUtils.equalsNormalizedOnSystem(
        directory,(String)ref.getProperty(PROPERTY_CORE_DIR))){
        return ref;
      }
    }
  }
  return null;
}

代码示例来源:origin: net.sourceforge.pmd/pmd-core

public void add(File file) throws IOException {
  if (configuration.isSkipDuplicates()) {
    // TODO refactor this thing into a separate class
    String signature = file.getName() + '_' + file.length();
    if (current.contains(signature)) {
      System.err.println("Skipping " + file.getAbsolutePath()
          + " since it appears to be a duplicate file and --skip-duplicate-files is set");
      return;
    }
    current.add(signature);
  }
  if (!FilenameUtils.equalsNormalizedOnSystem(file.getAbsoluteFile().getCanonicalPath(),
      file.getAbsolutePath())) {
    System.err.println("Skipping " + file + " since it appears to be a symlink");
    return;
  }
  if (!file.exists()) {
    System.err.println("Skipping " + file + " since it doesn't exist (broken symlink?)");
    return;
  }
  SourceCode sourceCode = configuration.sourceCodeFor(file);
  add(sourceCode);
}

代码示例来源:origin: apache/stanbol

public String getCoreForDirectory(String coreNameOrPath) {
  if(coreNameOrPath.charAt(coreNameOrPath.length()-1) != File.separatorChar){
    coreNameOrPath = coreNameOrPath+File.separatorChar;
  }
  for(SolrCore core : server.getCores()){
    String instanceDir = core.getCoreDescriptor().getInstanceDir();
    if(FilenameUtils.equalsNormalizedOnSystem(
      coreNameOrPath, instanceDir)){
      return core.getName();
    }
  }
  return null;
}
public CoreContainer getCoreContainer() {

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.commons.solr.managed

public String getCoreForDirectory(String coreNameOrPath) {
  if(coreNameOrPath.charAt(coreNameOrPath.length()-1) != File.separatorChar){
    coreNameOrPath = coreNameOrPath+File.separatorChar;
  }
  for(SolrCore core : server.getCores()){
    String instanceDir = core.getCoreDescriptor().getInstanceDir();
    if(FilenameUtils.equalsNormalizedOnSystem(
      coreNameOrPath, instanceDir)){
      return core.getName();
    }
  }
  return null;
}
public CoreContainer getCoreContainer() {

相关文章