Example usage for com.google.common.io Resources getResource

List of usage examples for com.google.common.io Resources getResource

Introduction

In this page you can find the example usage for com.google.common.io Resources getResource.

Prototype

public static URL getResource(String resourceName) 

Source Link

Document

Returns a URL pointing to resourceName if the resource is found using the Thread#getContextClassLoader() context class loader .

Usage

From source file:hmi.animation.RenamingMap.java

public static BiMap<String, String> renamingMapFromFileOnClasspath(String filename) throws IOException {
    return renamingMap(Resources.toString(Resources.getResource(filename), Charsets.UTF_8));
}

From source file:org.apache.sentry.core.common.utils.PolicyFiles.java

public static void copyToDir(FileSystem fs, Path dest, String... resources)
        throws FileNotFoundException, IOException {
    for (String resource : resources) {
        InputStream in = Resources.getResource(resource).openStream();
        FSDataOutputStream out = fs.create(new Path(dest, resource));
        long bytes = ByteStreams.copy(in, out);
        in.close();/* w  ww . j av a  2s  . c  o  m*/
        out.hflush();
        out.close();
        LOGGER.debug("Copying " + resource + " to " + dest + ", bytes " + bytes);
    }
}

From source file:com.fitbur.core.config.util.ResourceService.java

public InputStream getResourceAsStream(String resource) throws IOException {
    return Resources.getResource(resource).openStream();
}

From source file:org.kitesdk.data.filesystem.DatasetTestUtilities.java

private static URI findSchemaURI(String resource) {
    try {//from   www . j  a  v a  2s . c o  m
        return Resources.getResource(resource).toURI();
    } catch (URISyntaxException e) {
        throw new IllegalStateException("Cannot load " + resource);
    }
}

From source file:com.zenika.doclipser.api.DockerConfig.java

public DockerConfig() {
    final URL url = Resources.getResource(Constants.PROPERTY_FILE_NAME);
    Properties properties = readPropertyFile(url);

    version = properties.getProperty(Constants.PROPERTY_DOCKER_API_VERSION);
    uri = properties.getProperty(Constants.PROPERTY_DOCKER_URI);
    username = properties.getProperty(Constants.PROPERTY_USERNAME);
    password = properties.getProperty(Constants.PROPERTY_PASSWORD);
    email = properties.getProperty(Constants.PROPERTY_EMAIL);
    serverAddress = properties.getProperty(Constants.PROPERTY_DOCKER_SERVER_ADDRESS);
    dockerCertPath = properties.getProperty(Constants.PROPERTY_DOCKER_CERT_PATH);

    URL fullUrl = null;//w w w.j ava  2  s.c om
    try {
        fullUrl = FileLocator.resolve(url);
    } catch (IOException e) {
        e.printStackTrace();
    }
    propertiesFileFullPath = fullUrl == null ? null : fullUrl.getPath();
}

From source file:org.apache.isis.viewer.wicket.ui.components.about.AboutPanelFactory.java

private static String versionFromManifest() {
    try {//from w w w.  j  av  a  2s  .  c  om
        return Resources.toString(Resources.getResource(META_INF_POM_PROPERTIES), Charset.defaultCharset());
    } catch (final Exception ex) {
        return "UNKNOWN";
    }
}

From source file:de.nx42.maps4cim.util.ImageJUtils.java

public static ImagePlus openFromResource(String res) {
    URL url = Resources.getResource(res);
    Image img = Toolkit.getDefaultToolkit().getImage(url);
    return new ImagePlus(null, img);
}

From source file:keywhiz.service.config.ResourcesHttpsConnectorFactory.java

private static File resolveResource(File resource) {
    return Paths.get(Resources.getResource(resource.getPath()).getPath()).toFile();
}

From source file:com.google.gapid.glviewer.ShaderSource.java

public static Shader loadShader(String name) {
    return loadShader(Resources.getResource("shaders/" + name + ".glsl"));
}

From source file:com.dgraf.nashornplayground.Bindings.java

public Bindings() {
    super();/*from  w  w w. j  a  v a  2  s  .com*/
    runner = new nashornScriptRunner();
    scriptset = new nashornScriptset();
    try {
        scriptset.setName("Bindings");
        URL url = Resources.getResource("com/dgraf/nashornplayground/examples/bindings.js");
        String script = Resources.toString(url, Charsets.UTF_8);
        scriptset.setScript(script);
    } catch (IOException ex) {
        Logger.getLogger(HelloWorld.class.getName()).log(Level.SEVERE, null, ex);
    }
}