Android File Move moveFile(File source, File target)

Here you can find the source of moveFile(File source, File target)

Description

move File

License

Open Source License

Declaration

public static void moveFile(File source, File target)
            throws IOException 

Method Source Code

/*//from   w ww .j  a v  a2  s  .  c o m
 * Copyright (c) 2015. Philip DeCamp
 * Released under the BSD 2-Clause License
 * http://opensource.org/licenses/BSD-2-Clause
 */

import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class Main{
    private static final String MOVE_COMMAND;
    public static void moveFile(File source, File target)
            throws IOException {
        Process p = Runtime.getRuntime().exec(
                new String[] { MOVE_COMMAND, source.getAbsolutePath(),
                        target.getAbsolutePath() });

        try {
            int ret = p.waitFor();

            if (ret != 0)
                throw new IOException("Failed to move "
                        + source.getAbsolutePath() + " to "
                        + target.getAbsolutePath());

        } catch (InterruptedException ex) {
            p.destroy();
            throw new InterruptedIOException(ex.getMessage());
        }

    }
}

Related

  1. move(File source, File destination)
  2. move(String sourceFileName, String destinationFileName)
  3. moveFile(String sourceFileName, String destPath)
  4. moveSubFiles(String sourceFileName, String destPath)
  5. move(String input, String output)
  6. moveFile(File src, File dest)
  7. moveFile(String in, String out)