Returns a new {@link HttpFileBuilder} that builds an {@link HttpFile} from the classpath resource
at the specified {@code path} using the specified {@link ClassLoader}.
776282
public static HttpFileBuilder ofResource(ClassLoader classLoader, String path) {
        requireNonNull(classLoader, "classLoader");
        requireNonNull(path, "path");

        // Strip the leading slash.
        if (path.startsWith("/")) {
            path = path.substring(1);
        }

        // Retrieve the resource URL.
        final URL url = classLoader.getResource(path);
        if (url == null || url.getPath().endsWith("/")) {
            // Non-existent resource.
            return new NonExistentHttpFileBuilder();
        }

        // Convert to a real file if possible.
        if ("file".equals(url.getProtocol())) {
            File f;
            try {
                f = new File(url.toURI());
            } catch (URISyntaxException ignored) {
                f = new File(url.getPath());
            }

            return of(f);
        }

        return new ClassPathHttpFileBuilder(url);
    }
662009
public static InputStream asInputStream(Path path) throws IOException {
		Validate.notNull(path, "path is null");
		return Files.newInputStream(path);
	}
1138660
private InputStream getResourceInputStream(String path) {
		InputStream is = config.getContext().getResourceAsStream(path);
		if (is == null) {
			try {
				is = ClassLoaderResourceUtils.getResourceAsStream(path, this);
			} catch (FileNotFoundException e) {
				throw new BundlingProcessException(e);
			}
		}

		return is;
	}
1239604
public Optional<URL> getResource(String path) {
        boolean isDirectory = isDirectory(path);

        if (!isDirectory) {
            URL url = classLoader.getResource(prefixPath(path));
            return Optional.ofNullable(url);
        }
        return Optional.empty();
    }
754718
public static void addToClasspath(final String url, final ClassLoader classLoader) {
        checkNotNull("url", url);
        try {
            addToClasspath(new URL(url), classLoader);
        } catch (final MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }
653891
public static BufferedWriter newBufferedWriter(Path path) throws IOException {
        FileUtils.checkDirectory(path.getParent());
        BufferedWriter bufferedWriter;
        if (path.toFile().getName().endsWith(".gz")) {
            bufferedWriter = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(path.toFile()))));
        } else {
            bufferedWriter = Files.newBufferedWriter(path, Charset.defaultCharset());
        }
        return bufferedWriter;
    }
645198
public final IO.Readable open(String path, byte priority) throws IOException {
		Object pointer = getResourcePointer(path);
		AbstractClassLoader cl = this;
		if (pointer == null) {
			if (subLoaders != null)
				for (AbstractClassLoader sub : subLoaders) {
					pointer = sub.getResourcePointer(path);
					if (pointer != null) {
						cl = sub;
						break;
					}
				}
			if (pointer == null)
				throw new FileNotFoundException(path);
		}
		return cl.openResourcePointer(pointer, priority);
	}
852170
protected String findClasspathFile(final String path) throws IOException {
        if (path == null){
            return null;
        }
        final File file = new File(path);
        if (file.exists()){
            return file.getAbsolutePath();
        }
        return createTmpFile(path).getAbsolutePath();
    }
642612
public static InputStreamResource inputStreamResource(final String path,
                                                          final SupplierWithThrowable<InputStream, IOException> supplier) {
        return new InputStreamResource(path, supplier);
    }
3760
public static ClassFileReader newInstance(Path path) throws IOException {
        if (!Files.exists(path)) {
            throw new FileNotFoundException(path.toString());
        }

        if (Files.isDirectory(path)) {
            return new DirectoryReader(path);
        } else if (path.getFileName().toString().endsWith(".jar")) {
            return new JarFileReader(path);
        } else {
            return new ClassFileReader(path);
        }
    }
1166789
static PathFileObject createSimplePathFileObject(JavacPathFileManager fileManager,
            final Path path) {
        return new PathFileObject(fileManager, path) {
            @Override
            String inferBinaryName(Iterable<? extends Path> paths) {
                Path absPath = path.toAbsolutePath();
                for (Path p: paths) {
                    Path ap = p.toAbsolutePath();
                    if (absPath.startsWith(ap)) {
                        try {
                            Path rp = ap.relativize(absPath);
                            if (rp != null) // maybe null if absPath same as ap
                                return toBinaryName(rp);
                        } catch (IllegalArgumentException e) {
                            // ignore this p if cannot relativize path to p
                        }
                    }
                }
                return null;
            }
        };
    }
843583
public static ClassFileReader newInstance(Path path, Runtime.Version version) throws IOException {
        if (Files.notExists(path)) {
            throw new FileNotFoundException(path.toString());
        }

        if (Files.isDirectory(path)) {
            return new DirectoryReader(path);
        } else if (path.getFileName().toString().endsWith(".jar")) {
            return new JarFileReader(path, version);
        } else {
            return new ClassFileReader(path);
        }
    }
1070768
@Deprecated
    public static ResourceHandler.Builder fileHandler(Path path) {
        return new Builder().withResourceProviderFactory(ResourceProviderFactory.fileBased(path));
    }
1336555
public static ClassFileReader newInstance(Path path, JarFile jf) throws IOException {
        return new JarFileReader(path, jf);
    }
448812
public static DynamicClassLoader create(ClassLoader parent,
                                          PathImpl classDir, PathImpl sourceDir,
                                          String args, String encoding)
  {
    DynamicClassLoader loader = new DynamicClassLoader(parent);
    loader.addLoader(new CompilingLoader(loader, classDir, sourceDir, args, encoding));

    loader.init();
    
    return loader;
  }
521577
public static DynamicClassLoader create(PathImpl path)
  {
    ClassLoader parent = Thread.currentThread().getContextClassLoader();

    return create(parent, path);
  }
649975
public static File asFile(String generalPath) throws IOException {
		if (StringUtils.startsWith(generalPath, CLASSPATH_PREFIX)) {
			String resourceName = StringUtils.substringAfter(generalPath, CLASSPATH_PREFIX);
			return getFileByURL(ResourceUtil.asUrl(resourceName));
		}
		try {
			// try URL
			return getFileByURL(new URL(generalPath));
		} catch (MalformedURLException ex) {
			// no URL -> treat as file path
			return new File(generalPath);
		}
	}