Here you can find the source of move(File in, File out)
public static void move(File in, File out) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; public class Main { public static void move(File in, File out) throws IOException { copy(in, out);/* w w w.j a v a 2 s .c o m*/ delete(in); } public static void copy(File in, File out) throws IOException { if (in.exists() && in != null && out != null) { if (!out.exists()) { if (in.isDirectory()) { out.mkdirs(); } else { out.createNewFile(); } } String source = in.isDirectory() ? "directory" : "file"; String target = out.isDirectory() ? "directory" : "file"; if (!source.equals(target)) { throw new IOException("Can't duplicate " + source + " as " + target); } else { if (source.equals("directory")) { File[] files = in.listFiles(); for (File file : files) { copy(file, new File(out, file.getName())); } } else { FileChannel inCh = new FileInputStream(in).getChannel(); FileChannel outCh = new FileOutputStream(out).getChannel(); inCh.transferTo(0, inCh.size(), outCh); } } } } public static void delete(File file) { if (file != null && file.exists()) { if (file.isDirectory()) { File[] files = file.listFiles(); for (File f : files) { delete(f); } } file.delete(); } } }