I'm creating a Java Program that identifies whether the given path is either file or directory without using any package.
What are the attributes that distinguishes between a file and a directory ?
Also, how does isFile() and isDirectory() method from java.io.File works at backend?
I tried separating from the extension, but found that directory name also can contain characters after period like directoryName.extension. I've some research on internet but failed to come with solid solution.
class FileCheck{
public static void main(String[] args){
boolean checkOne = isFile(C:\users);
boolean checkTwo = isFile(C:\users\file.txt);
boolean checkThree = isDirectory(C:\users);
boolean checkFour = isDirectory(C:\users\file.txt);
}
}
Don't get confused with isFile() and isDirectory() method. They are user created functions; not imported from java.io.File.
I expect if I pass C:\users as argument, it should return true value from isDirectory() function and when C:\users\file.txt, it should return false. Same logic applies for isFile() method.