Move a directory with java.nio.file.Files in Java

Description

The following code shows how to move a directory with java.nio.file.Files.

Example


import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
//from   ww w.  j  a  v  a 2s .  c o  m
public class Main {

  public static void main(String[] args) throws Exception{
    Path sourceFile = Paths.get("C:/home/docs");
    Path destinationFile = Paths.get("C:/home/music/docs");
    Files.move(sourceFile, destinationFile);

  }
}




















Home »
  Java Tutorial »
    I/O »




Binary File
Byte Array
CharSet
Checksum
Console
Create Copy Move Delete
Directory
Drive
Encode Decode
File Attribute
File Lock
File System
GZIP
Jar File
NIO Buffer
Path
Scanner
StreamTokenizer
Temporary File
Text File
Zip