Here you can find the source of moveFile(File source, File target)
public static void moveFile(File source, File target) throws IOException
/*//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()); } } }