File rename
In this chapter you will learn:
Rename a file
boolean renameTo(File dest)
renames the file denoted by this abstract pathname.
The return value from the method above tells if the renaming action is successful.
It may return false
if the file is opened in another application.
import java.io.File;
//j ava 2s. c o m
public class Main {
public static void main(String[] args) {
File file = new File("c:/a.htm");
file.renameTo(new File("c:/abc.html"));
}
}
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » I/O