Find the filename or directory name from a file object.
Find the filename or directory name from a file object.
The getName method of file class returns the name of the file or directory of the current file object.
import java.io.File;
public class FileExample {
public static void main(String[] args) {
File file = new File("d:\\temp");
System.out.println(file.getName());
}
}
Tags: File, file class examples, File examples, java.io, java.io.File
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply