Public Static void throws Exception { new File ("Bin/dyan.txt"); System.out.println (System.getproperty ("User.dir")); System.out.println (File.exists ()); System.out.println (File.length ()); }
Relative paths, additional path information is required to resolve to the represented file.
By default, java.io
classes in a package always resolve relative pathname based on the current user directory.
This directory is specified by the System Properties user.dir
and is typically the calling directory for the Java virtual machine.
The content of my user.dir output is E:\core_wkspace\TestProject
So the relative path is written as Bin/dyan.txt
New File ("E:\\core_wkspace\\testproject\\bin\\yan.txt");
The absolute path is not said, the full path name, without any additional information can be located to the represented file.
Path to file build instance: Absolute path and relative path