final boolean downloadFile(String destFile, ObjectInputStream input, InputStream in, byte[] key) {
        try {

            FileOutputStream fout = new FileOutputStream(destFile + ".tmp");
            BufferedOutputStream bout = new BufferedOutputStream(fout);

            // get the length of the file:
            long length = input.readLong();

            // initialized the cipher and cipher stream:
            AEScipher.init(Cipher.DECRYPT_MODE, fileAESKey, fileIV);

            int len;
            byte[] buffer = new byte[128];

            while (length > 0) {
                len = input.read(buffer);
                if (len < 0) {
                    break;
                }
                //bout.write(buffer, 0, len);
                if (length < buffer.length) {
                    bout.write(AEScipher.doFinal(buffer, 0, len));
                } else {
                    bout.write(AEScipher.update(buffer, 0, len));
                }

                length -= len;
            }

            bout.flush();
            bout.close();

            System.out.println("done.");
            getFile(destFile + ".tmp", destFile, key, length);
            File f = new File(destFile + ".tmp");
            f.delete();
            return true;

        } catch (Exception e) {
            //System.err.println(e);
            e.printStackTrace();
            return false;
        }
    }