File.isFile() has the following syntax.
public boolean isFile()
In the following code shows how to use File.isFile() method.
// ww w. jav a2s. c o m import java.io.File; public class Main { public static void main(String[] args) { File f = new File("c:"); // true if the file path is a file, else false boolean bool = f.isFile(); // get the path String path = f.getPath(); System.out.println(path + " is file? " + bool); // create new file f = new File("c:/test.txt"); // true if the file path is a file, else false bool = f.isFile(); // get the path path = f.getPath(); System.out.print(path + " is file? " + bool); } }
The code above generates the following result.