Use File class and isFile() method.
This method returns true if file is a file otherwise false
import java.io.File; public class IsFile { public static void main(String[] args) { File file = new File("readme.txt"); boolean result = file.isFile(); if( result == true ) System.out.println( "It is a file" ); else System.out.println( "File doesn't exists or isn't a file" ); } }
No comments:
Post a Comment