Skip to content

Instantly share code, notes, and snippets.

@gandra
Created August 19, 2019 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gandra/911f465217011e2dfec1a8e561c0bb57 to your computer and use it in GitHub Desktop.
Save gandra/911f465217011e2dfec1a8e561c0bb57 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.nio.file.Files;
import java.nio.file.*;
public class MoveFilesDemo {
public static void main(String[] args) throws IOException
{
Path temp = Files.move
(Paths.get("C:\\temp\\testfile.txt"),
Paths.get("C:\\Program Files\\testfile.txt"));
if(temp != null)
{
System.out.println("File renamed and moved successfully");
}
else
{
System.out.println("Failed to move the file");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment