Java Resource File getBytes(Class contextClass, String resourceName)

Here you can find the source of getBytes(Class contextClass, String resourceName)

Description

get Bytes

License

LGPL

Declaration

public static byte[] getBytes(Class<?> contextClass, String resourceName) throws IOException 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.io.IOException;

import java.net.URL;

import com.google.common.io.Resources;

public class Main {
    public static byte[] getBytes(String resourceName) throws IOException {
        URL resourceUrl = Resources.getResource(resourceName);
        return getBytes(resourceUrl);
    }//w ww .  j  a  v  a2s .  c o m

    public static byte[] getBytes(Class<?> contextClass, String resourceName) throws IOException {
        URL resourceUrl = Resources.getResource(contextClass, resourceName);
        return getBytes(resourceUrl);
    }

    private static byte[] getBytes(URL resourceUrl) throws IOException {
        return Resources.toByteArray(resourceUrl);
    }
}

Related

  1. copyResource(String name)
  2. expendResource(String fileName)
  3. getAllResources(Class clazz, String resource)
  4. getBaseLineFolder(String resourceFile)
  5. getBundlesContainingResource(BundleContext bundleContext, String resourcePattern)
  6. getClassResource(Class clazz)
  7. getContentAsString(String resource)
  8. getDefaultWebXmlResourceLocation()
  9. getEntriesFromResourceBundle(String rbName, Map map)