public void encryptFile(File read, File write) {
        {
            InputStream in = null;
            OutputStream out = null;
            OutputStream fileOut = null;
            try {
                cipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
                in = new FileInputStream(read);
                fileOut = new FileOutputStream(write);
                out = new CipherOutputStream(fileOut, cipher);
                int redbytes = 0;
                byte[] buffer = new byte[1024];
               while((redbytes=in.read(buffer))!=-1){
                   //System.out.print("Total bytes encryption : "+ redbytes);
                    out.write(buffer,0,redbytes);
                }
                out.flush();
            } catch (InvalidAlgorithmParameterException ex) {
                ex.printStackTrace();
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            } catch (InvalidKeyException ik) {
                ik.printStackTrace();
            } finally {
                try {
                     out.close();
                    in.close();
                    fileOut.close();
                   
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
        }
    }