MCPcopy Create free account
hub / github.com/davidgiven/luje / isAbsolute

Method isAbsolute

lib/java/io/File.java:766–784  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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

Callers 2

properPathMethod · 0.95
checkURIMethod · 0.45

Calls 3

isLetterMethod · 0.95
lengthMethod · 0.65
charAtMethod · 0.65

Tested by

no test coverage detected