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

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

Introduction

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

Prototype

public static String toString(URL url, Charset charset) throws IOException 

Source Link

Document

Reads all characters from a URL into a String , using the given character set.

Usage

From source file:com.djd.fun.util.ExpectData.java

/**
 * @param resourceName file path under resources dir
 * @return string represents content of the file
 *//*  w  w w  . jav a  2s  .c o  m*/
public static String toString(String resourceName) {
    URL url = Resources.getResource(resourceName);
    try {
        return Resources.toString(url, Charsets.UTF_8);
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}

From source file:com.palominolabs.testutil.ResourceUtil.java

public static String readResource(String path) throws IOException {
    return Resources.toString(ResourceUtil.class.getResource(path), Charsets.UTF_8);
}

From source file:org.eclipse.scada.configuration.component.common.lib.Helper.java

static String loadResource(final String resourceName) {
    final URL updateUrl = Resources.getResource(Helper.class, resourceName);
    try {//  www.  j  a  va 2s.c o m
        return Resources.toString(updateUrl, Charset.forName("UTF-8"));
    } catch (final IOException e) {
        throw new RuntimeException(String.format("Unable to load '%s'", resourceName), e);
    }
}

From source file:com.optimizely.ab.BenchmarkUtils.java

public static String getProfilingDatafile(String datafilePath) throws IOException {
    return Resources.toString(Resources.getResource(datafilePath), Charsets.UTF_8);
}

From source file:com.spotify.docker.FixtureUtil.java

public static String fixture(final String filename) throws IOException {
    return Resources.toString(Resources.getResource(filename), Charsets.UTF_8).trim();
}

From source file:mongis.utils.TextFileUtils.java

public static String readFileFromJar(String url) throws IOException {
    return Resources.toString(TextFileUtils.class.getResource(url), Charset.forName("UTF-8"));
}

From source file:org.tomitribe.beryllium.Utility.java

public static String fileContent(final String filePath) throws IOException {
    return Resources.toString(Resources.getResource(filePath), Charset.defaultCharset());
}

From source file:org.sonar.plugins.pmd.PmdTestUtils.java

public static String getResourceContent(String path) {
    try {/*from  w ww . j av a  2s .  co m*/
        return Resources.toString(Resources.getResource(PmdTestUtils.class, path), Charsets.UTF_8);
    } catch (IOException e) {
        throw new IllegalArgumentException("Could not load resource " + path, e);
    }
}

From source file:de.appsolve.padelcampus.utils.FileUtil.java

public static String getFileContents(String fileName) throws IOException {
    URL url = Resources.getResource(fileName);
    return Resources.toString(url, Charsets.UTF_8);
}

From source file:com.mobiaware.util.ResourceHelpers.java

private static String fixture(final String filename, final Charset charset) throws IOException {
    return Resources.toString(Resources.getResource(filename), charset).trim();
}