Android Utililty Methods File Move

List of utility methods to do File Move

Description

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

Method

Filemove(File file, File directory)
Moves file into directory.
Check.arg().validFile(file);
Check.arg().validDirectory(directory);
return rename(file, new File(directory, file.getName()));
booleanmove(File source, File destination)
move
if (!source.exists()) {
    return false;
destination.delete();
return source.renameTo(destination);
booleanmove(String sourceFileName, String destinationFileName)
move
return move(new File(sourceFileName), new File(destinationFileName));
voidmoveFile(String sourceFileName, String destPath)
move File
File src = new File(sourceFileName);
if (!src.exists()) {
    throw new Exception("save file[" + sourceFileName
            + "] to file[" + destPath + "] failed:"
            + sourceFileName + " not exist.");
try {
    FileUtil.fileCopy(sourceFileName, destPath);
...
voidmoveSubFiles(String sourceFileName, String destPath)
move Sub Files
File src = new File(sourceFileName);
File dest = new File(destPath);
if (!dest.exists())
    dest.mkdirs();
if (src.isFile())
    return;
else {
    File[] files = src.listFiles();
...
voidmove(String input, String output)
This class moves an input file to output file
File inputFile = new File(input);
File outputFile = new File(output);
try {
    inputFile.renameTo(outputFile);
} catch (Exception ex) {
    throw new Exception("Can not mv" + input + " to " + output
            + ex.getMessage());
voidmoveFile(File source, File target)
move File
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 "
...
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.");
StringmoveFile(String in, String out)
Moves a file, overwriting any existing file at the destination.
copyFile(in = assertNotEmpty("in", in), out);
delete(in);
return out;