Here you can find the source of isAbsolutePath(String path)
Parameter | Description |
---|---|
path | the input String. |
public static boolean isAbsolutePath(String path)
/*/*from w w w.j a va 2s . c o m*/ Copyright 1996-2008 Ariba, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. $Id: //ariba/platform/util/core/ariba/util/core/FileUtil.java#24 $ */ import ariba.util.log.Log; import java.io.File; import java.io.IOException; import java.io.FileFilter; import java.io.FilenameFilter; import java.util.Random; import java.util.List; public class Main{ /** Determines if the path specified by a given String is an absolute path or not. On UNIX systems, a pathname is absolute if its prefix is "/". On Win32 systems, a pathname is absolute if its prefix is a drive specifier followed by "\\", or if its prefix is "\\". @param path the input String. @return <b>true</b> if the path is an absolute path. <b>false</b> otherwise. Returns false if the input string is null or empty or blank. @aribaapi documented */ public static boolean isAbsolutePath(String path) { if (StringUtil.nullOrEmptyOrBlankString(path)) { return false; } if (SystemUtil.isWin32()) { // windows find the index of the driver number. Then // we start searching from the index immediately after // it. Note that this code works even if the drive // character (':') does not exist because indexOf then // returns -1, and we start searching from index 0. int indexToSearch = path.indexOf(":") + 1; return (path.startsWith("\\", indexToSearch) || path.startsWith("/", indexToSearch)); } // unix // ToDo: should I also check for "\\"? People could specify windows style // path character on Unix? return path.startsWith("/"); } }