Java Path Is Absolute isAbsolutePath(String path)

Here you can find the source of isAbsolutePath(String path)

Description

Determine whether a file system path is absolute or relative.

License

Open Source License

Parameter

Parameter Description
path The path in question.

Return

True if absolute, else false.

Declaration

public static boolean isAbsolutePath(String path) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 Arapiki Solutions Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from w ww .jav a  2  s  .com*/
 *    "Peter Smith <psmith@arapiki.com>" - initial API and 
 *        implementation and/or initial documentation
 *******************************************************************************/

public class Main {
    /**
     * Determine whether a file system path is absolute or relative.
     * 
     * @param path The path in question.
     * @return True if absolute, else false.
     */
    public static boolean isAbsolutePath(String path) {

        return ((path != null) && (!path.isEmpty()) && ((path.charAt(0) == '/') || (path.charAt(0) == '\\')));
    }
}

Related

  1. isAbsolutePath(String path)
  2. isAbsolutePath(String path)
  3. isAbsolutePath(String path)
  4. isAbsolutePath(String path)
  5. isAbsolutePath(String path)
  6. isAbsolutePath(String path)
  7. isAbsolutePath(String path)
  8. IsAbsolutePath(String strPath)