Java Is Relative Path isRelativePath(String path)

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

Description

is Relative Path

License

Open Source License

Parameter

Parameter Description
path a parameter

Return

true if path is relative

Declaration

public static boolean isRelativePath(String path) throws Exception 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    /**/*from   w  ww .  j av  a  2 s. c  o  m*/
     * @param path
     * @return true if path is relative
     */
    public static boolean isRelativePath(String path) throws Exception {
        String osName = System.getProperty("os.name");

        if (osName.toLowerCase().startsWith("linux")) {
            if (path.startsWith(File.separator)) {
                return false;
            } else {
                return true;
            }
        } else if (osName.toLowerCase().startsWith("windows")) {
            if (path.indexOf(":") != -1) {
                return false;
            } else {
                return true;
            }
        }
        throw new Exception(
                "isRelativePath - doesn't support " + System.getProperty("os.name") + " operating system");
    }
}

Related

  1. isRelative(String path)
  2. isRelativePath(final String filePath)
  3. isRelativePath(String candidatePath)
  4. isRelativePath(String fileName)
  5. isRelativePath(String path)
  6. isRelativePath(String path)
  7. isRelativePath(String path)