List of usage examples for org.apache.commons.io FileUtils writeByteArrayToFile
public static void writeByteArrayToFile(File file, byte[] data) throws IOException
From source file:org.jbpm.document.service.impl.DocumentStorageServiceImpl.java
@Override public Document saveDocument(Document document, byte[] content) { if (document == null || StringUtils.isEmpty(document.getIdentifier())) return null; File destination = getFileByPath(document.getIdentifier() + "/" + document.getName()); try {//from w w w .j a va2 s . com FileUtils.writeByteArrayToFile(destination, content); } catch (IOException e) { log.error("Error writing file {}: {}", document.getName(), e); } return document; }
From source file:org.jbpm.form.builder.services.impl.fs.FSFileService.java
public String storeFile(String fileName, byte[] content) throws FileException { String url = baseUrl + fileSeparator + fileName; File file = new File(url); try {/*from ww w . j av a2 s . c o m*/ FileUtils.writeByteArrayToFile(file, content); } catch (IOException ex) { throw new FileException(ex.getMessage(), ex); } return url; }
From source file:org.jcodec.common.io.Buffer.java
public void writeTo(File file) throws IOException { FileUtils.writeByteArrayToFile(file, toArray()); }
From source file:org.jdal.system.SystemUtils.java
public static void open(byte[] data, String extension) { if (data != null && Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); File file;/* ww w .ja v a 2s .c o m*/ try { file = File.createTempFile("tmp", "." + extension); file.deleteOnExit(); FileUtils.writeByteArrayToFile(file, data); desktop.open(file); } catch (IOException e) { String message = "No ha sido posible abrir el fichero"; JOptionPane.showMessageDialog(null, message, "Error de datos", JOptionPane.ERROR_MESSAGE); } } }
From source file:org.jdal.util.processor.JasperReportFileProcessor.java
public static void main(String[] args) { try {// ww w. j a v a2s . c o m JasperReport report = JasperCompileManager .compileReport("/home/jose/Projects/telmma/Documents/Code/testParameters.jrxml"); System.out.println("Query en el jasper: " + report.getQuery().getText()); for (JRParameter param : report.getParameters()) { if (!param.isSystemDefined()) System.out.println(param.getName()); } Map<String, Object> parameters = new HashMap<String, Object>(); // TEST parameters.put("NombreCiudad", "Huelva"); JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource()); byte[] reportBin = JasperExportManager.exportReportToPdf(jasperPrint); if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); File outputFile; try { outputFile = File.createTempFile("simple_report", ".pdf"); //outputFile.deleteOnExit(); // Create the file with the raw data provided by the file processor FileUtils.writeByteArrayToFile(outputFile, reportBin); System.out.println("OutputFile -> " + outputFile.getName() + " " + outputFile.getTotalSpace()); desktop.open(outputFile); } catch (IOException e) { e.printStackTrace(); } } } catch (JRException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.jenkinsci.plugins.scriptsecurity.scripts.EntryApprovalTest.java
@Override Entry create() throws Exception { final File file = tmpFolderRule.newFile(); final byte[] bytes = new byte[1024]; random.nextBytes(bytes);/* w ww .ja v a 2s. c o m*/ FileUtils.writeByteArrayToFile(file, bytes); return entry(file); }
From source file:org.jenkinsci.plugins.zap.ZAPDriver.java
/** * Generates security report for one format. Reports are saved into build's workspace. * //from w w w .j ava 2 s . c o m * @param listener * of type BuildListener: the display log listener during the Jenkins job execution. * @param clientApi * of type ClientApi: the ZAP client API to call method. * @param workspace * of type FilePath: a {@link FilePath} representing the build's workspace. * @param reportFormat * of type ZAPJReport: the format of the report. * @param filename * of type String: the filename for the report. * @throws IOException * @throws ClientApiException */ private void saveReport(BuildListener listener, ClientApi clientApi, FilePath workspace, ZAPReport reportFormat, String filename) throws IOException, ClientApiException { final String fullFileName = filename + "." + reportFormat.getFormat(); Path p = Paths.get(workspace.getRemote(), NAME_REPORT_DIR); File f = p.toFile(); if (!f.exists()) { f.mkdir(); } f = new File(p.toAbsolutePath().toString(), fullFileName); FileUtils.writeByteArrayToFile(f, reportFormat.generateReport(clientApi, API_KEY)); Utils.loggerMessage(listener, 1, "[ {0} ] SAVED TO [ {1} ]", reportFormat.getFormat().toUpperCase(), f.getAbsolutePath()); }
From source file:org.jgrades.backup.creator.EncryptArchiveJob.java
private File saveEncryptedZip(byte[] encryptBytes) throws IOException { String encryptedZipName = backup.getPath() + File.separator + "jg-internal-" + backup.getName() + ".bak"; File encryptInternalZip = new File(encryptedZipName); FileUtils.writeByteArrayToFile(encryptInternalZip, encryptBytes); return encryptInternalZip; }
From source file:org.jgrades.backup.creator.EncryptArchiveJob.java
private void saveSignatureOfZip(File encryptInternalZip) throws IOException { byte[] signature = signatureProvider.sign(FileUtils.readFileToByteArray(encryptInternalZip)); File encryptInternalZipSignature = new File(encryptInternalZip.getAbsolutePath() + ".sign"); FileUtils.writeByteArrayToFile(encryptInternalZipSignature, signature); }
From source file:org.jgrades.lic.api.crypto.encrypt.LicenceSaver.java
public void saveLicence(byte[] encryptedXmlFileBytes) throws IOException { FileUtils.writeByteArrayToFile(licenceFile, encryptedXmlFileBytes); }