Here you can find the source of getBytes(Class> contextClass, String resourceName)
public static byte[] getBytes(Class<?> contextClass, String resourceName) throws IOException
//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); } }