Generate byte[] array for a file with Java

Sometimes we need to generate a bye[] to represent a file. For example, you might need to do this if you want to put a file to remote database while invoking restful service.

    /**
     * generate byte[] array for a file
     */
    public static byte[] generateBytes(String sFile) {
        File fFile = new File(sFile);
        FileInputStream fInputStream = null;

        ByteArrayOutputStream bArrayOutput = new ByteArrayOutputStream();
        byte[] bBuffer = new byte[4086];
        try {
            fInputStream = new FileInputStream(fFile);
            for (int iCounter; (iCounter = fInputStream.read(bBuffer)) != -1;) {
                bArrayOutput.write(bBuffer, 0, iCounter);
                System.out.println("read " + iCounter + " bytes");
            }
        } catch (IOException e) {
            System.err.println("Error: " + e.getMessage());
        } finally {
            try {
                fInputStream.close();
            } catch (Exception e) {
                System.err.println("Error: " + e.getMessage());
            }
        }
        return bArrayOutput.toByteArray();
//        byte[] bBytes = bArrayOutput.toByteArray();
//        File fNewFile = new File("newfilename");
//        FileOutputStream fOutput = new FileOutputStream(fNewFile);
//        fOutput.write(bBytes);
//        fOutput.flush();
//        fOutput.close();
    }