- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {}
public DataSet extractDataSet(String file, String encode) throws Exception { FileObject fileObject = null; BufferedReader reader = null; try { fileObject = FileObjectUtil.findFileObject(file, false); reader = new BufferedReader(new InputStreamReader(fileObject.getInputStream(), encode)); CSVParser parser = new CSVParser(reader, CSVFormat.DEFAULT); return parser.extractDataSet(); } catch (Exception e) { throw new ScriptException(ResourceBundleUtil.getResourceMessage("excel", "file.find.error", file), e); } finally { if (reader != null) { reader.close(); } if (fileObject != null) { fileObject.clean(); } } }
public boolean validateXmlSignature(String userId, String signedXmlPath) throws XMLSignatureException { FileObject file = null; try { file = VFS.resolveFile(signedXmlPath); return validateXmlSignature(userId, file.getInputStream()); } catch (XMLSignatureException e) { throw e; } catch (Exception e) { throw new XMLSignatureException(String.format("验证路径[%s]的XML签名发生异常", signedXmlPath), e); } finally { if (file != null) { file.clean(); } } }
public void createXmlSignature(String userId, String sourceXmlPath, OutputStream output) throws XMLSignatureException { FileObject file = null; try { file = VFS.resolveFile(sourceXmlPath); createXmlSignature(userId, file.getInputStream(), output); } catch (XMLSignatureException e) { throw e; } catch (Exception e) { throw new XMLSignatureException(String.format("生成路径[%s]的XML签名发生异常", sourceXmlPath), e); } finally { if (file != null) { file.clean(); } } }
private void addProtocol(WeiXinCert cert) { try { KeyStore keyStore = KeyStore.getInstance(cert.getCertType()); FileObject certObjcet = VFS.resolveFile(cert.getCertPath()); char[] password = cert.getPassword().toCharArray(); try { keyStore.load(certObjcet.getInputStream(), password); } finally { certObjcet.clean(); } KeyManagerFactory factory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); factory.init(keyStore, password); // Trust own CA and all self-signed certs SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(factory.getKeyManagers(), null, null); ProtocolSocketFactory protocolSocketFactory = new AuthSSLProtocolSocketFactory(VFS.resolveFile(cert.getCertPath()), cert.getPassword(), null, null); Protocol authhttps = new Protocol(HTTPS_PROTOCOL, protocolSocketFactory, 443); Protocol.registerProtocol(HTTPS_PROTOCOL, authhttps); } catch (Exception e) { throw new RuntimeException(e); } }
} finally { if (fileObject != null) { fileObject.clean();
} finally { if (fileObject != null) { fileObject.clean();