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

org.guppy4j.io.ResourceHelperImpl Maven / Gradle / Ivy

There is a newer version: 0.0.7
Show newest version
package org.guppy4j.io;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;

/**
 * Default resource helper
 */
public class ResourceHelperImpl implements ResourceHelper {

    private final StreamHelper streamHelper;

    public ResourceHelperImpl(StreamHelper streamHelper) {
        this.streamHelper = streamHelper;
    }

    @Override
    public String getResourceAsString(String resourceLocation) throws IOException {
        final InputStream stream = getClass().getResourceAsStream(resourceLocation);
        final byte[] bytes = streamHelper.copyToByteArray(stream);
        return new String(bytes, Charset.forName("UTF-8"));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy