List of usage examples for org.apache.commons.io IOUtils copy
public static void copy(Reader input, OutputStream output) throws IOException
Reader
to bytes on an OutputStream
using the default character encoding of the platform, and calling flush. From source file:com.gemstone.gemfire.internal.logging.log4j.custom.CustomConfiguration.java
public static File createConfigFileIn(final File targetFolder) throws IOException, URISyntaxException { URL resource = openConfigResource(); File targetFile = new File(targetFolder, CONFIG_FILE_NAME); IOUtils.copy(resource.openStream(), new FileOutputStream(targetFile)); assertThat(targetFile).hasSameContentAs(new File(resource.toURI())); return targetFile; }
From source file:de.cismet.cids.custom.utils.nas.CidsActionClient.java
/** * DOCUMENT ME!/* ww w . j a v a2s.co m*/ * * @param args DOCUMENT ME! */ public static void main(final String[] args) { final CidsActionClient client = new CidsActionClient("cids", "http://s102x002:8890"); final ActionTask at = new ActionTask(); at.setParameters(new HashMap<String, Object>()); final File f = new File("ci_test_klein.zip"); // final ActionTask.Status status = client.getTaskStatus("dxf", "1406735852661"); // System.out.println("Status " + status); final ActionTask resultInstance = client.createTask("dummydxf", at, f, new MediaType("application", "zip"), true); System.out.println("Resulting instance: " + resultInstance.getKey()); ActionTask.Status status = client.getTaskStatus("dummydxf", resultInstance.getKey()); while (status != ActionTask.Status.FINISHED) { try { Thread.sleep(1000); status = client.getTaskStatus("dummydxf", resultInstance.getKey()); } catch (InterruptedException ex) { Exceptions.printStackTrace(ex); } } final File tmpFile = client.getTaskResult(File.class, "dummydxf", resultInstance.getKey(), "dxfOutput"); final File result = new File("result.dxf"); try { IOUtils.copy(new FileInputStream(tmpFile), new FileOutputStream(result)); } catch (IOException ex) { Exceptions.printStackTrace(ex); } System.out.println("Done"); }
From source file:eu.scape_project.pc.droid.DroidIdentificationTest.java
/** * Set up.//w w w . j ava 2 s. c o m * @throws Exception */ @BeforeClass public static void setUpClass() throws Exception { URL sigFileV67Url = new URL(SIGNATURE_FILE_V67_URL); InputStream sigFileStream = sigFileV67Url.openStream(); File tmpSigFile = File.createTempFile("tmpsigfile", ".xml"); FileOutputStream fos = new FileOutputStream(tmpSigFile); IOUtils.copy(sigFileStream, fos); fos.close(); dihj = DroidIdentification.getInstance(tmpSigFile.getAbsolutePath()); }
From source file:net.landora.video.info.file.FileHasher.java
public static String getED2KHash(File file) { InputStream is = null;/*from www . j a v a 2 s . c o m*/ try { is = new BufferedInputStream(new FileInputStream(file)); Edonkey e2dkChecksum = new Edonkey(); IOUtils.copy(is, new CheckedOutputStream(new NullOutputStream(), e2dkChecksum)); return e2dkChecksum.getHexValue(); } catch (Exception e) { LoggerFactory.getLogger(FileHasher.class).error("Error hashing file.", e); return null; } finally { IOUtils.closeQuietly(is); } }
From source file:com.youTransactor.uCube.LogManager.java
public static boolean storeTransactionLog(byte[] logs1, byte[] logs2) { if (context == null || (logs1 == null && logs2 == null)) { return false; }/*from w w w. j a v a2s . c o m*/ File logDir = context.getDir(LOG_DIR, Context.MODE_PRIVATE); try { FileOutputStream out = new FileOutputStream( new File(logDir, timestampFormatter.format(new Date()).replace(':', '-').replace(' ', '_'))); if (logs1 != null) { IOUtils.copy(new ByteArrayInputStream(logs1), out); } if (logs2 != null) { IOUtils.copy(new ByteArrayInputStream(logs2), out); } return true; } catch (Exception e) { debug(LogManager.class.getSimpleName(), "unable to store transaction logs", e); return false; } }
From source file:gov.nih.nci.cacis.xds.StaticMetadataSupplier.java
@Override public String createDocEntry() throws IOException { final InputStream staticDocEntry = getClass().getClassLoader().getResourceAsStream("docEntry.xml"); final StringWriter writer = new StringWriter(); IOUtils.copy(staticDocEntry, writer); return writer.toString(); }
From source file:eu.scape_project.pc.droid.DroidIdentificationTaskTest.java
/** * Set up./*from ww w. j a v a2s .c om*/ * @throws Exception */ @BeforeClass public static void setUpClass() throws Exception { URL sigFileV67Url = new URL(SIGNATURE_FILE_V67_URL); InputStream sigFileStream = sigFileV67Url.openStream(); File tmpSigFile = File.createTempFile("tmpsigfile", ".xml"); FileOutputStream fos = new FileOutputStream(tmpSigFile); IOUtils.copy(sigFileStream, fos); fos.close(); dihj = DroidIdentificationTask.getInstance(tmpSigFile.getAbsolutePath()); }
From source file:de.burlov.crypt.CryptUtils.java
static public byte[] decrypt(byte[] ciphertext, byte[] key) throws IOException { CryptInputStream in = new CryptInputStream(new ByteArrayInputStream(ciphertext), new SerpentEngine(), key); ByteArrayOutputStream bout = new ByteArrayOutputStream(); IOUtils.copy(in, bout); return bout.toByteArray(); }
From source file:brut.androlib.mod.SmaliMod.java
public static boolean assembleSmaliFile(InputStream is, DexBuilder dexBuilder, boolean verboseErrors, boolean printTokens, File smaliFile) throws IOException, RecognitionException { // copy our filestream into a tmp file, so we don't overwrite File tmp = File.createTempFile("BRUT", ".bak"); tmp.deleteOnExit();// w w w. j av a 2 s. c om OutputStream os = new FileOutputStream(tmp); IOUtils.copy(is, os); os.close(); return assembleSmaliFile(tmp, dexBuilder, verboseErrors, printTokens); }
From source file:com.giacomodrago.immediatecrypt.messagecipher.Compression.java
public static byte[] decompress(byte[] plaintext) { try {/*from ww w .java2 s.c om*/ ByteArrayOutputStream writer = new ByteArrayOutputStream(); ByteArrayInputStream reader = new ByteArrayInputStream(plaintext); GZIPInputStream gzipStream = new GZIPInputStream(reader); IOUtils.copy(gzipStream, writer); gzipStream.close(); writer.flush(); writer.close(); return writer.toByteArray(); } catch (IOException ex) { return null; // Invalid source data } }