Here you can find the source of getResourceBytes(String path)
static public byte[] getResourceBytes(String path)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { static public byte[] getResourceBytes(String path) { InputStream s = ClassLoader.getSystemClassLoader().getResourceAsStream(path); try {/*from ww w .j a va 2s. co m*/ return readAll(s); } finally { try { s.close(); } catch (IOException e) { e.printStackTrace(); } } } static public byte[] readAll(InputStream s) { byte[] temp = new byte[1024]; ByteArrayOutputStream os = new ByteArrayOutputStream(); try { while (true) { int read = s.read(temp, 0, temp.length); if (read <= 0) break; os.write(temp, 0, read); } } catch (IOException e) { e.printStackTrace(); } return os.toByteArray(); } }