Java Rename File renameExcludedFiles(File existingBinaryFolder, Collection excludedBids)

Here you can find the source of renameExcludedFiles(File existingBinaryFolder, Collection excludedBids)

Description

Will attempt to rename each file that is bid.dat where possible bids are passed in the excludedBids collection to bid.exclude.

License

Apache License

Parameter

Parameter Description
existingBinaryFolder a parameter
excludedBids a parameter

Return

-1 if successful, or the bid of the rename that failed if something went wrong.

Declaration

public static int renameExcludedFiles(File existingBinaryFolder, Collection<Integer> excludedBids) 

Method Source Code

//package com.java2s;
/*/*from   ww w .  j a  va2s  .c  om*/
 *   Copyright 2010 MINT Working Group
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

import java.io.File;

import java.util.*;

public class Main {
    public static final String BINARY_FILE_EXTENSION = "dat";
    public static final String EXCLUDED_BINARY_FILE_EXTENSION = "exclude";

    /**
     * Will attempt to rename each file that is bid.dat where possible bids are
     * passed in the excludedBids collection to bid.exclude. Will return -1 if
     * successful and will return the bid of the rename that failed if something
     * went wrong.
     *
     * @param existingBinaryFolder
     * @param excludedBids
     * @return -1 if successful, or the bid of the rename that failed if something
     * went wrong.
     */
    public static int renameExcludedFiles(File existingBinaryFolder, Collection<Integer> excludedBids) {
        for (int bid : excludedBids) {
            File oldFile = new File(existingBinaryFolder, bid + "." + BINARY_FILE_EXTENSION);
            File newFile = new File(existingBinaryFolder, bid + "." + EXCLUDED_BINARY_FILE_EXTENSION);

            if (!oldFile.renameTo(newFile))
                return bid;
        }

        return -1;
    }
}

Related

  1. renameContigs(File aliasFile, File cytobandFile, File seqDir)
  2. renameDirectory(File directory, File newDirectory)
  3. renameDirectory(File fromDir, File toDir)
  4. renameDirectory(String in_currentDirectoryPath, String in_newDirectoryPath)
  5. renameDirectory(String newDir, String oldDir)
  6. renameExistingWithRetries(final File fromFile, final File toFile)
  7. renameFile(File src, File dest)
  8. renameFile(String source, String dest)
  9. renameFile(String sourcePath, String targetPath)