/** * Performs copy operation between currentNodeStream and outputStream using buffer length. * * @throws IOException */ private void doCopy() throws IOException { int copied = IOUtil.copy(currentNodeStream, outputStream, BUFFER_LENGTH); if (copied == -1) { currentNodeStream.close(); currentNodeStream = null; endAsset(); } }
/** * Performs copy operation between currentNodeStream and outputStream using buffer length. * * @throws IOException */ private void doCopy() throws IOException { int copied = IOUtil.copy(currentNodeStream, outputStream, BUFFER_LENGTH); if (copied == -1) { currentNodeStream.close(); currentNodeStream = null; endAsset(); } }
/** * Copies the contents from an InputStream to an OutputStream and closes both streams. * * @param input * @param output * @throws IOException * If a problem occurred during any I/O operations during the copy, but on closing the streams these * will be ignored and logged at {@link Level#FINER} */ public static void copyWithClose(InputStream input, OutputStream output) throws IOException { try { copy(input, output); } finally { try { input.close(); } catch (final IOException ignore) { if (log.isLoggable(Level.FINER)) { log.finer("Could not close stream due to: " + ignore.getMessage() + "; ignoring"); } } try { output.close(); } catch (final IOException ignore) { if (log.isLoggable(Level.FINER)) { log.finer("Could not close stream due to: " + ignore.getMessage() + "; ignoring"); } } } }
/** * Copies the contents from an InputStream to an OutputStream and closes both streams. * * @param input * @param output * @throws IOException * If a problem occurred during any I/O operations during the copy, but on closing the streams these * will be ignored and logged at {@link Level#FINER} */ public static void copyWithClose(InputStream input, OutputStream output) throws IOException { try { copy(input, output); } finally { try { input.close(); } catch (final IOException ignore) { if (log.isLoggable(Level.FINER)) { log.finer("Could not close stream due to: " + ignore.getMessage() + "; ignoring"); } } try { output.close(); } catch (final IOException ignore) { if (log.isLoggable(Level.FINER)) { log.finer("Could not close stream due to: " + ignore.getMessage() + "; ignoring"); } } } }
/** * Serializes the invocation with a custom form * * @serialData After all non-transient fields are written, we send the {@link Archive} contents encoded as ZIP. */ private void writeObject(final ObjectOutputStream out) throws IOException { // Default write of non-transient fields out.defaultWriteObject(); // Write as ZIP final InputStream in = archive.as(ZipExporter.class).exportAsInputStream(); try { IOUtil.copy(in, out); // Don't close the outstream // Write the ID explicitly out.writeObject(id); } finally { // In case we get an InputStream type that supports closing in.close(); } // Log if (log.isLoggable(Level.FINER)) { log.finer("Wrote archive: " + archive.toString()); } }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.exporter.StreamExporter#exportTo(java.io.OutputStream) */ @Override public void exportTo(final OutputStream target) throws ArchiveExportException, IllegalArgumentException { // Precondition checks if (target == null) { throw new IllegalArgumentException("Target must be specified"); } // Get Stream final InputStream in = this.exportAsInputStream(); try { // Write out try { IOUtil.copy(in, target); } catch (final IOException e) { throw new ArchiveExportException("Error encountered in exporting archive to " + target, e); } } finally { // Close try { in.close(); } catch (final IOException ioe) { // Just log log.warning("Could not close " + in + ": " + ioe); } } }
/** * Serializes the invocation with a custom form * * @serialData After all non-transient fields are written, we send the {@link Archive} contents encoded as ZIP. */ private void writeObject(final ObjectOutputStream out) throws IOException { // Default write of non-transient fields out.defaultWriteObject(); // Write as ZIP final InputStream in = archive.as(ZipExporter.class).exportAsInputStream(); try { IOUtil.copy(in, out); // Don't close the outstream // Write the ID explicitly out.writeObject(id); } finally { // In case we get an InputStream type that supports closing in.close(); } // Log if (log.isLoggable(Level.FINER)) { log.finer("Wrote archive: " + archive.toString()); } }
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.exporter.StreamExporter#exportTo(java.io.OutputStream) */ @Override public void exportTo(final OutputStream target) throws ArchiveExportException, IllegalArgumentException { // Precondition checks if (target == null) { throw new IllegalArgumentException("Target must be specified"); } // Get Stream final InputStream in = this.exportAsInputStream(); try { // Write out try { IOUtil.copy(in, target); } catch (final IOException e) { throw new ArchiveExportException("Error encountered in exporting archive to " + target, e); } } finally { // Close try { in.close(); } catch (final IOException ioe) { // Just log log.warning("Could not close " + in + ": " + ioe); } } }
private File createJar(String baseName, Path dir) throws IOException { File out = getOutputFile(baseName, dir); if (!out.getParentFile().exists() && !out.getParentFile().mkdirs()) { this.log.error("Failed to create parent directory for: " + out.getAbsolutePath()); } ZipExporter exporter = this.archive.as(ZipExporter.class); try (FileOutputStream fos = new FileOutputStream(out)) { if (executable) { try (InputStream is = getLaunchScript()) { IOUtil.copy(is, fos); } } exporter.exportTo(fos); } if (executable) { if (!out.setExecutable(true)) { this.log.error("Failed to set executable flag"); } } return out; }
private File createJar(String baseName, Path dir) throws IOException { File out = getOutputFile(baseName, dir); if (!out.getParentFile().exists() && !out.getParentFile().mkdirs()) { this.log.error("Failed to create parent directory for: " + out.getAbsolutePath()); } ZipExporter exporter = this.archive.as(ZipExporter.class); try (FileOutputStream fos = new FileOutputStream(out)) { if (executable) { try (InputStream is = getLaunchScript()) { IOUtil.copy(is, fos); } } exporter.exportTo(fos); } if (executable) { if (!out.setExecutable(true)) { this.log.error("Failed to set executable flag"); } } return out; }
IOUtil.copy(zipStream, output); archive.add(new ByteArrayAsset(output.toByteArray()), entryName); zipStream.closeEntry();
IOUtil.copy(zipStream, output); archive.add(new ByteArrayAsset(output.toByteArray()), entryName); zipStream.closeEntry();
@Test @InSequence(1) public void shouldBeAbleToInjectURL(@ArquillianResource URL base) throws Exception { System.out.println(base); Assert.assertNotNull(base); IOUtil.copy(base.openStream(), System.out); }
/** * Serializes the invocation with a custom form * * @serialData After all non-transient fields are written, we send the {@link Archive} contents encoded as ZIP. */ private void writeObject(final ObjectOutputStream out) throws IOException { // Default write of non-transient fields out.defaultWriteObject(); // Write as ZIP final InputStream in = archive.as(ZipExporter.class).exportAsInputStream(); try { IOUtil.copy(in, out); // Don't close the outstream } finally { // In case we get an InputStream type that supports closing in.close(); } // Log if (log.isLoggable(Level.FINER)) { log.finer("Wrote archive: " + archive.toString()); } }