Here you can find the source of isAbsolutePath(String path)
Parameter | Description |
---|---|
The | path to check. |
public static boolean isAbsolutePath(String path)
//package com.java2s; /*// w w w .j a v a 2 s.c o m * JLib - Publicitas Java library v1.2.0. * * Copyright (c) 2005, 2006, 2007, 2008, 2009 Publicitas SA. * Licensed under LGPL (LGPL-LICENSE.txt) license. */ public class Main { /** * Checks if the specified path is absolute. * <ul> * <li><b>In Windows</b> the path is absolute if it starts with a letter unit: * <pre>C:/this/that/...</pre></li> * <li><b>In Unix</b> the path is absolute if it starts with a "/": * <pre>/root/data/...</pre></li> * </ul> * @param The path to check. * @return <i>true</i> if the path is absolute. */ public static boolean isAbsolutePath(String path) { String osName; if (path == null) return false; if (path.length() == 0) return false; osName = System.getProperty("os.name").toLowerCase(); if (osName.startsWith("win")) { if (path.length() < 2) return false; if (path.charAt(1) == ':') return true; } else if (path.startsWith("/")) return true; return false; } }