我使用此代码将文件提取到p7s文件中。
try{
byte[] buffer = new byte[(int) novo.length()];
DataInputStream in = new DataInputStream(new FileInputStream(novo));
in.readFully(buffer);
in.close();
//Corresponding class of signed_data is CMSSignedData
CMSSignedData signature = new CMSSignedData(buffer);
Store cs = signature.getCertificates();
SignerInformationStore signers = signature.getSignerInfos();
Collection c = signers.getSigners();
Iterator it = c.iterator();
//the following array will contain the content of xml document
byte[] data = null;
while (it.hasNext()) {
SignerInformation signer = (SignerInformation) it.next();
// Collection certCollection = cs.getMatches(signer.getSID());
// Iterator certIt = certCollection.iterator();
// X509CertificateHolder cert = (X509CertificateHolder) certIt.next();
CMSProcessable sc = signature.getSignedContent();
data = (byte[]) sc.getContent();
}
FileUtils.writeByteArrayToFile(new File(recuperarPasta(numeroProtocolo, especialidade, Diretorio.PROTOCOLO, null, tipoProtocolo) + numeroProtocolo +".PDF"), data);
}catch (Exception e ){
throw new IOException(e.getMessage());
}
但是对于大文件,我有一个堆空间,如何使用输出流提取文件?
tks