Java Utililty Methods File Move nui

List of utility methods to do File Move nui

Description

The list of methods to do File Move nui are organized into topic(s).

Method

voidmove(File from, File to)
move
Files.move(from.toPath(), to.toPath(), REPLACE_EXISTING);
voidmove(File from, File to)
move
copyFile(from, to);
from.delete();
voidmove(File in, File out)
move
copy(in, out);
delete(in);
booleanmove(File source, File destination)
Moves a file.
logger.entering("de.axelwernicke.mypod.util.FileUtils", "move");
boolean success = false;
if ((source == null) || (destination == null)) {
    return false;
if (source.equals(destination)) {
    return true;
success = source.renameTo(destination);
if (success) {
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("moved file from " + source + " to " + destination + " by renaming");
} else {
    long bytesCopied = copy(source, destination);
    if (bytesCopied == source.length()) {
        int cnt = 0;
        boolean srcDel = false;
        boolean destDel = false;
        do {
            srcDel = source.delete();
            if (srcDel) {
                success = true;
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("moved file from " + source + " to " + destination + " by copying");
            else {
                success = false;
                destDel = destination.delete();
            cnt++;
            logger.warning("mv " + source + " to " + destination + " " + cnt + ". src deleted: " + srcDel
                    + " dest deleted: " + destDel);
            try {
                Thread.sleep(500);
            } catch (Exception e) {
                ;
        } while (!(srcDel || destDel) && (cnt < 1000));
    } else {
        success = false;
        boolean delDest = destination.delete();
        logger.warning("moving file from " + source + " to " + destination
                + " by copying failed (copied bytes != filesize), destination file deleted: " + delDest);
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("moved file from " + source + " to " + destination + " by copying");
logger.exiting("de.axelwernicke.mypod.util.FileUtils", "move");
return success;
Filemove(final File from, final File to, final boolean replace)
move
if (!replace && to.exists())
    throw new IOException(
            "Can't rename " + from.getName() + " to " + to.getName() + ": The target file already exists");
if (!RUNNINGJAVA6) {
    if (replace)
        Files.move(from.toPath(), to.toPath(), StandardCopyOption.REPLACE_EXISTING,
                StandardCopyOption.ATOMIC_MOVE);
    else
...
voidmove(String sourceFile, String targetFile)
Moves one file to another.
copy(sourceFile, targetFile);
new File(sourceFile).delete();
voidmoveFile(File from, File to)
move File
copyFile(from, to);
from.delete();
voidmoveFile(File source, File destination)
Moves the specified source file to the specified destination.
if (destination.exists()) {
    forceDeletion(destination);
Files.move(source.toPath(), destination.toPath());
voidmoveFile(File src, File dest)
Moves a file from src to dest.
copyFile(src, dest);
if (!delete(src)) {
    throw new IOException("Failed to delete the src file '" + src + "' after copying.");
booleanmoveFile(final File srcFile, final File destFile)
Copy a file.
return moveFile(srcFile, destFile, true);