Java Path File Read nio loadFile(String path)

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

Description

load File

License

Apache License

Declaration

public static File loadFile(String path) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.nio.file.*;

public class Main {
    public static File loadFile(String path) {
        if (path == null) {
            path = "/";
        }/*  w  w  w.j a va2  s . com*/

        File f = new File(path);
        if (f.exists()) {
            return f.getAbsoluteFile();
        }

        if (!path.startsWith("/")) {
            path = "/" + path;
        }

        return new File(Paths.get("").toAbsolutePath().toString() + path.trim());
    }
}

Related

  1. getTestClassPathURLClassLoader(ClassLoader parent)
  2. load(Path p, PrintStream errorStream, String propertyInfo)
  3. loadFile(final Path filePath)
  4. loadFile(final Path p)
  5. loadFile(Path file)
  6. loadFromFile(Path path)
  7. loadJSON(Path path)
  8. loadProperties(Path filePath)
  9. loadProperties(Supplier classLoader, String classpathResource)