Objective
Current project directory
Windows for E:\project\testpro\
Linux for /project/testpro/
Obtaining an absolute path condition in the Windows environment
Use A/B/C as the path to get the absolute path: new File ("a/b/c"). GetAbsolutePath ()
The resulting path is E:\project\testpro\sspt-sppt\a\b\c
Use the/A/B/C path to get the absolute path to the new File ("/a/b/c"). GetAbsolutePath ()
It gets the path to E:\a\b\c ,
The difference lies in whether or not the directory was added before /
In Linux, the identity is the root directory.
Under window, it is replaced with a:\, b:\, c \, D:\ And so on, the selection of the drive letter is the standard of the drive letter of the item in Windows, and if the item is in a directory of the E drive letter, the selected drive letter is e:\.
Obtaining an absolute path condition in a Linux environment
Use A/B/C as the path to get the absolute path: new File ("a/b/c"). GetAbsolutePath ()
The resulting path is /project/testpro/sspt-sppt/a/b/c
Use the/A/B/C path to get the absolute path to the new File ("/a/b/c"). GetAbsolutePath ()
The resulting path is /a/b/c
Absolute path relative path problem under Java File Linux Windows