Indicates if this file's pathname is absolute. Whether a pathname is absolute is platform specific. On UNIX, absolute paths must start with the character '/'; on Windows it is absolute if either it starts with '\\' (to represent a file server), or a letter followed by a colon. @return true
()
| 764 | * @see #getPath |
| 765 | */ |
| 766 | public boolean isAbsolute() { |
| 767 | if (File.separatorChar == '\\') { |
| 768 | // for windows |
| 769 | if (path.length() > 1 && path.charAt(0) == File.separatorChar |
| 770 | && path.charAt(1) == File.separatorChar) { |
| 771 | return true; |
| 772 | } |
| 773 | if (path.length() > 2) { |
| 774 | if (Character.isLetter(path.charAt(0)) && path.charAt(1) == ':' |
| 775 | && (path.charAt(2) == '/' || path.charAt(2) == '\\')) { |
| 776 | return true; |
| 777 | } |
| 778 | } |
| 779 | return false; |
| 780 | } |
| 781 | |
| 782 | // for Linux |
| 783 | return (path.length() > 0 && path.charAt(0) == File.separatorChar); |
| 784 | } |
| 785 | |
| 786 | /** |
| 787 | * Indicates if this file represents a <em>directory</em> on the |
no test coverage detected