Using file class vs path class to get paths in java
We know that File class can also return the path of a File.So why did java come up with Path class to get paths of a file.Reason is java File class has few problems.
It does not throw exceptions or specific errors if something fails.For example File.delete() returns true or false if file is deleted successfully.
But if it fails to delete the file it doesn't tell whether deletion failed because file does not exist or we don't have permissions to delete the file.
Another example is File.rename -->It works differently on different OS like windows ,macs etc although they are supposed to work the same on all OS.
Another issue is File class has no support for symbolic links.Symbolic links are used when one files points to another
Also File class does not provide info about meta data in a file . like file permissions etc
One last issue is many methods in File class don't perform well with lots of data.Like if we use File class to find all files in a directory the method can hang is there are lots of files in that directory.