Here you can find the source of readFileRaw(File file)
public static byte[] readFileRaw(File file) throws IOException
//package com.java2s; /***//from w w w . j a v a 2 s. com * Copyright (C) 2010 Johan Henriksson * This code is under the Endrov / BSD license. See www.endrov.net * for the full text and how to cite. */ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static byte[] readFileRaw(File file) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); FileInputStream is = new FileInputStream(file); byte[] buf = new byte[1024]; int ret; while ((ret = is.read(buf)) != -1) os.write(buf, 0, ret); is.close(); return os.toByteArray(); } }