Compare files by extension.

@param sourceFile
the source file
@param fileToCompare
the file to compare
@return true if the extension are equal, otherwise false.
766096
public static boolean compareFilesByExtension(final File sourceFile, final File fileToCompare)
	{
		return CompareFileExtensions
			.compareFiles(sourceFile, fileToCompare, true, false, true, true, true, true)
			.getFileExtensionEquality();
	}
606414
public static IFileContentResultBean compareFiles(final File sourceFile,
		final File fileToCompare)
	{
		return compareFiles(sourceFile, fileToCompare, true, false, false, true, false, true);
	}
1087361
public static <T extends Comparable<T>> int checkCompare(T a, T b) {
        return a == null ?
                b == null ? 0 : -1 :
                    b == null ? 1 : a.compareTo(b);
      }
1117264
def is_source_file(args, filepath):
    """"""
    if args.extension:
        return os.path.splitext(filepath)[1] in args.extension
    else:
        return os.path.splitext(filepath)[1] in _CPP_EXTENSIONS
470475
@Override
    public int compare(DependencyReportToArchiveEdgeModel o1, DependencyReportToArchiveEdgeModel o2)
    {
        String path1 = o1.getFullPath();
        String path2 = o2.getFullPath();
        return filePathComparator.compare(path1, path2);
    }
177441
protected boolean doesFileMatch(final File file, final CSNodeWrapper node) {
        if (!node.getNodeType().equals(CommonConstants.CS_NODE_FILE)) return false;

        // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare
        if (file.getUniqueId() != null && file.getUniqueId().matches("^\\d.*")) {
            return file.getUniqueId().equals(Integer.toString(node.getId()));
        } else {
            // Since a content spec doesn't contain the database ids for the nodes use what is available to see if the files match
            return file.getId().equals(node.getEntityId());
        }
    }
414393
@Override
    public int compare(File o1, File o2) {
        return -1 * new Long(o1.lastModified()).compareTo(new Long(o2.lastModified()));
    }
1028716
public function equals(Node $toCompare)
    {
        // Only compare, if given instance is a literal
        if ($toCompare->isLiteral() && $this->getDatatype()->equals($toCompare->getDatatype())) {
            return $this->getValue() === $toCompare->getValue() && $this->getLanguage() == $toCompare->getLanguage();
        }

        return false;
    }
75382
public static void copy(String fromFile, String toFile) throws IOException {

        File inputFile = new File(fromFile);
        File outputFile = new File(toFile);
        if (!outputFile.getParentFile().isDirectory()) {
            outputFile.getParentFile().mkdirs();
        }
        FileInputStream in = new FileInputStream(inputFile);
        FileOutputStream out = new FileOutputStream(outputFile);

        // transfer bytes from in to out
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
        }
        in.close();
        out.close();
    }
1069774
public static boolean equal(File file1, File file2) throws IOException {
    checkNotNull(file1);
    checkNotNull(file2);
    if (file1 == file2 || file1.equals(file2)) {
      return true;
    }

    /*
     * Some operating systems may return zero as the length for files denoting system-dependent
     * entities such as devices or pipes, in which case we must fall back on comparing the bytes
     * directly.
     */
    long len1 = file1.length();
    long len2 = file2.length();
    if (len1 != 0 && len2 != 0 && len1 != len2) {
      return false;
    }
    return asByteSource(file1).contentEquals(asByteSource(file2));
  }
359766
@Nonnull
  public static FileIOError renameFile (@Nonnull final File aSourceFile, @Nonnull final File aTargetFile)
  {
    ValueEnforcer.notNull (aSourceFile, "SourceFile");
    ValueEnforcer.notNull (aTargetFile, "TargetFile");

    // Does the source file exist?
    if (!FileHelper.existsFile (aSourceFile))
      return EFileIOErrorCode.SOURCE_DOES_NOT_EXIST.getAsIOError (EFileIOOperation.RENAME_FILE, aSourceFile);

    // Are source and target different?
    if (EqualsHelper.equals (aSourceFile, aTargetFile))
      return EFileIOErrorCode.SOURCE_EQUALS_TARGET.getAsIOError (EFileIOOperation.RENAME_FILE, aSourceFile);

    // Does the target file already exist?
    if (aTargetFile.exists ())
      return EFileIOErrorCode.TARGET_ALREADY_EXISTS.getAsIOError (EFileIOOperation.RENAME_FILE, aTargetFile);

    // Is the source parent directory writable?
    final File aSourceParentDir = aSourceFile.getParentFile ();
    if (aSourceParentDir != null && !aSourceParentDir.canWrite ())
      return EFileIOErrorCode.SOURCE_PARENT_NOT_WRITABLE.getAsIOError (EFileIOOperation.RENAME_FILE, aSourceFile);

    // Is the target parent directory writable?
    final File aTargetParentDir = aTargetFile.getParentFile ();
    if (aTargetParentDir != null && aTargetParentDir.exists () && !aTargetParentDir.canWrite ())
      return EFileIOErrorCode.TARGET_PARENT_NOT_WRITABLE.getAsIOError (EFileIOOperation.RENAME_FILE, aTargetFile);

    // Ensure parent of target directory is present
    FileHelper.ensureParentDirectoryIsPresent (aTargetFile);

    try
    {
      final EFileIOErrorCode eError = aSourceFile.renameTo (aTargetFile) ? EFileIOErrorCode.NO_ERROR
                                                                         : EFileIOErrorCode.OPERATION_FAILED;
      return eError.getAsIOError (EFileIOOperation.RENAME_FILE, aSourceFile, aTargetFile);
    }
    catch (final SecurityException ex)
    {
      return EFileIOErrorCode.getSecurityAsIOError (EFileIOOperation.RENAME_FILE, ex);
    }
  }
862503
private static boolean existsBetterParityFile(
      Codec codec, FileStatus srcStat, Configuration conf) throws IOException {
    for (Codec c : Codec.getCodecs()) {
      if (c.priority > codec.priority) {
        ParityFilePair ppair = ParityFilePair.getParityFile(
            c, srcStat, conf);
        if (ppair != null) {
          return true;
        }
      }
    }
    return false;
  }
17703
private boolean isMatchingFileExtension() {
    String[] fileExtensions = mediaArgs.getFileExtensions();
    if (fileExtensions == null || fileExtensions.length == 0) {
      return true;
    }
    for (String fileExtension : fileExtensions) {
      if (StringUtils.equalsIgnoreCase(fileExtension, getFileExtension())) {
        return true;
      }
    }
    return false;
  }
976641
boolean checkSource(PathImpl sourceDir, String javaName)
  {
    try {
      while (javaName != null && ! javaName.equals("")) {
        int p = javaName.indexOf('/');
        String head;
      
        if (p >= 0) {
          head = javaName.substring(0, p);
          javaName = javaName.substring(p + 1);
        }
        else {
          head = javaName;
          javaName = null;
        }

        String []names = sourceDir.list();
        int i;
        for (i = 0; i < names.length; i++) {
          if (names[i].equals(head))
            break;
        }

        if (i == names.length)
          return false;

        sourceDir = sourceDir.lookup(head);
      }
    } catch (IOException e) {
      log.log(Level.FINE, e.toString(), e);
      
      return false;
    }

    return true;
  }
304580
public static boolean areEqual(Field destination,Field source){
		return getGenericString(destination).equals(getGenericString(source));
	}
1213507
@Override
    public int compareTo(ExportDataSource o) {
        int result;

        result = (m_partitionId - o.m_partitionId);
        if (result != 0) {
            return result;
        }

        result = m_database.compareTo(o.m_database);
        if (result != 0) {
            return result;
        }

        result = m_tableName.compareTo(o.m_tableName);
        if (result != 0) {
            return result;
        }

        return 0;
    }
371362
public int compare(FileStatus fileStatus1, FileStatus fileStatus2) {

    // Do the obligatory null checks.
    if ((fileStatus1 == null) && (fileStatus2 == null)) {
      return 0;
    }
    if (fileStatus1 == null) {
      return -1;
    }
    if (fileStatus2 == null) {
      return 1;
    }

    long modificationTime1 = fileStatus1.getModificationTime();
    long modificationTime2 = fileStatus2.getModificationTime();

    return (modificationTime1 < modificationTime2 ? -1
        : (modificationTime1 == modificationTime2 ? 0 : 1));
  }