All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javawebstack.httpserver.util.ResourceFileProvider Maven / Gradle / Ivy

Go to download

This library provides a routing and request mapping stack on top of the well known and industry proven eclipse jetty http server. It also supports websockets.

There is a newer version: 1.0.2
Show newest version
package org.javawebstack.httpserver.util;

import java.io.InputStream;

public class ResourceFileProvider implements FileProvider {

    private final ClassLoader classLoader;
    private final String prefix;

    public ResourceFileProvider(ClassLoader classLoader, String prefix) {
        this.classLoader = classLoader != null ? classLoader : ClassLoader.getSystemClassLoader();
        this.prefix = prefix;
    }

    public ResourceFileProvider(String prefix) {
        this(null, prefix);
    }

    public InputStream getFile(String path) {
        return classLoader.getResourceAsStream(prefix + ((!prefix.endsWith("/") && !path.startsWith("/")) ? "/" : "") + path);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy