Created
August 5, 2020 14:05
-
-
Save joakime/85aa90565b28728e218a89208b7fa2b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package fs; | |
| import java.nio.file.FileSystems; | |
| import java.nio.file.Path; | |
| public class AbsoluteTest | |
| { | |
| public static void main(String[] args) | |
| { | |
| isAbsolute("/is/it/abs"); | |
| isAbsolute("\\is\\it\\abs"); | |
| isAbsolute("\\\\ceres\\joakim\\abs"); | |
| isAbsolute("D:\\is\\it\\abs"); | |
| } | |
| private static void isAbsolute(String fileName) | |
| { | |
| // This is wrong, we cannot assume default FileSystem | |
| Path path = FileSystems.getDefault().getPath(fileName); | |
| System.out.printf("path [%s].isAbsolute=%b%n", fileName, path.isAbsolute()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment