public static byte[] unwrapVCF(File sourceFile,File tmpFile) throws FileNotFoundException, IOException {
  ZipArchiveInputStream in=null;
  FileOutputStream fos=null;
  String hmacString=null;
  try {
    in=new ZipArchiveInputStream(new FileInputStream(sourceFile));
    ArchiveEntry entry;
    in.getNextEntry();
    fos=new FileOutputStream(tmpFile);
    IOUtils.copy(in,fos);
    entry=in.getNextEntry();
    hmacString=entry.getName();
    return Utils.hexToBytes(hmacString);
  }
 catch (  StringIndexOutOfBoundsException e) {
    logger.error("Error parsing hmac: " + hmacString + " is no valid hex String",e);
    throw e;
  }
catch (  Exception e) {
    logger.error("Error unwrapping VCF file",e);
    throw e;
  }
 finally {
    if (fos != null) {
      fos.flush();
      fos.close();
    }
    if (in != null) {
      in.close();
    }
  }
}

public static byte [ ] unwrapVCF ( File sourceFile , File tmpFile ) throws FileNotFoundException , IOException { ZipArchiveInputStream in = null ; FileOutputStream fos = null ; String hmacString = null ; try { in = new ZipArchiveInputStream ( new FileInputStream ( sourceFile ) ) ; ArchiveEntry entry ; in . getNextEntry ( ) ; fos = new FileOutputStream ( tmpFile ) ; IOUtils . copy ( in , fos ) ; entry = in . getNextEntry ( ) ; hmacString = entry . getName ( ) ; return Utils . hexToBytes ( hmacString ) ; } catch ( StringIndexOutOfBoundsException e ) { logger . error ( "Error parsing hmac: " + hmacString + " is no valid hex String" , e ) ; throw e ; } catch ( Exception e ) { logger . error ( "Error unwrapping VCF file" , e ) ; throw e ; } finally { if ( fos != null ) { fos . flush ( ) ; fos . close ( ) ; } if ( in != null ) { in . close ( ) ; } } }
method extracts the vcf file stored within the zipped import file to the given destination file . it further returns the corresponding hmac stored within the archive .
