Does the provided path start with file:/ or <protocol>:// . @param path The path to test @return true if the supplied path starts with one of the recognised sequences.
(String path)
| 256 | * @return {@code true} if the supplied path starts with one of the recognised sequences. |
| 257 | */ |
| 258 | public static boolean isAbsoluteURI(String path) { |
| 259 | // Special case as only a single / |
| 260 | if (path.startsWith("file:/")) { |
| 261 | return true; |
| 262 | } |
| 263 | |
| 264 | // Start at the beginning of the path and skip over any valid protocol |
| 265 | // characters |
| 266 | int i = 0; |
| 267 | while (i < path.length() && isSchemeChar(path.charAt(i))) { |
| 268 | i++; |
| 269 | } |
| 270 | // Need at least one protocol character. False positives with Windows |
| 271 | // drives such as C:/... will be caught by the later test for "://" |
| 272 | if (i == 0) { |
| 273 | return false; |
| 274 | } |
| 275 | // path starts with something that might be a protocol. Look for a |
| 276 | // following "://" |
| 277 | return i + 2 < path.length() && path.charAt(i++) == ':' && path.charAt(i++) == '/' && path.charAt(i) == '/'; |
| 278 | } |
| 279 | |
| 280 | |
| 281 | /** |