public boolean writeFile(String filePath, byte[] bytes) {
        final int bufferSize = Integer.MAX_VALUE;
        OutputStream out = null;
        File f = new File(filePath);

        try {
            if (!f.exists())
                f.createNewFile();

            out = new BufferedOutputStream(new FileOutputStream(f));

            byte[] buffer = new byte[bufferSize];
            for (int i = 0; i < bytes.length; i++) {
                buffer[i % bufferSize] = bytes[i];
                // every n bytes write to the file (save resource intensive write for every byte..)
                if ((i % bufferSize) == 0) {
                    out.write(buffer, 0, bufferSize);
                }
                // only so few bytes left so write once we reach the end
                else if (i == (bytes.length - 1)) {
                    out.write(buffer, 0, buffer.length);
                }
            }

            return true;
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
            return false;
        } catch (IOException ioe) {
            ioe.printStackTrace();
            return false;
        } finally {
            try {
                out.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }