public static byte[] readFileBytes(File file) throws IOException {
        long lengthL = file.length();
        if (lengthL>Integer.MAX_VALUE)
            throw new IllegalArgumentException("File too big for byte array: "+file.getCanonicalPath());

        try (InputStream in = new FileInputStream(file)) {
            int length = (int)lengthL;
            byte[] array = new byte[length];
            int offset = 0;
            int count=0;
            while (offset < length && (count = in.read(array, offset, (length - offset)))>=0)
                offset += count;
            return array;
        }
    }
Reads the content of a file into a byte array
vespajlib/src/main/java/com/yahoo/io/IOUtils.java