Home Tutorial Java Core Files Java file isFile()

 
 

Share on Google+Share on Google+
Java file isFile()
Posted on: August 7, 2006 at 12:00 AM
Advertisement
This section demonstrates you the use of isFile() method.

Java file isFile()

This section demonstrates you the use of isFile() method.

Description of code

Java IO has provide several useful classes and methods. Among them, the method isFile() determines whether the pathname of the object represented by a File object is a file. In other words, it determines if a File object is representing a file. This method returns true if the object represented by the File object exists and is a file otherwise it returns false. It actually recognizes between files and directories. 

Here is the code:

import java.io.*;

public class JavaisFile {
	public static void main(String[] args) {
		File f = new File("C:/file.txt");
		if (f.isFile()) {
			System.out.println("It is a file");
		}
	}

}

Through the above code, you can check whether the file object representing the file.

It is a file
Advertisement

Related Tags for Java file isFile():


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 7, 2006

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com