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

pl.allegro.tech.hermes.common.ssl.provided.ResourceLoader Maven / Gradle / Ivy

The newest version!
package pl.allegro.tech.hermes.common.ssl.provided;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URI;

import static com.google.common.base.Strings.isNullOrEmpty;

interface ResourceLoader {
    default InputStream getResourceAsInputStream(URI location) throws FileNotFoundException {
        if ("classpath".equalsIgnoreCase(location.getScheme())) {
            return getClass().getClassLoader().getResourceAsStream(location.getSchemeSpecificPart());
        }
        return new FileInputStream(isNullOrEmpty(location.getPath()) ? location.getSchemeSpecificPart() : location.getPath());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy