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 static com.google.common.base.Strings.isNullOrEmpty;

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

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 - 2025 Weber Informatics LLC | Privacy Policy