Java URI to Base getBaseURI()

Here you can find the source of getBaseURI()

Description

get Base URI

License

Open Source License

Declaration

public static URI getBaseURI() 

Method Source Code


//package com.java2s;
// are made available under the terms of the Eclipse Public License v1.0

import java.io.File;

import java.net.URI;

public class Main {
    private static File basedir;
    private static URI baseURI;

    public static URI getBaseURI() {
        if (baseURI == null) {
            getBasedir();/*ww w. java 2s  .c  o m*/
        }
        return baseURI;
    }

    public static File getBasedir() {
        if (basedir == null) {
            String cwd = System.getProperty("basedir");

            if (cwd == null) {
                // System property not set.

                // Use CWD.
                cwd = System.getProperty("user.dir");
                basedir = new File(cwd);

                // Set the System property.
                System.setProperty("basedir", basedir.getAbsolutePath());
            } else {
                // Has system property, use it.
                basedir = new File(cwd);
            }

            baseURI = basedir.toURI();
        }

        return basedir;
    }
}

Related

  1. getBase(final URI uri)
  2. getBaseName(URI uri)
  3. getBaseURI()
  4. getBaseURI(final URI uri)