{@inheritDoc}

@see org.jboss.shrinkwrap.api.exporter.StreamExporter#exportAsInputStream()
355709
@Override
    public InputStream exportAsInputStream() {
        // Create export delegate
        final AbstractExporterDelegate<InputStream> exportDelegate = new TarBz2ExporterDelegate(this.getArchive());

        // Execute export
        return exportDelegate.export();
    }
171778
public void encode(InputStream inStream, OutputStream outStream)
        throws IOException {
        int     j;
        int     numBytes;
        byte    tmpbuffer[] = new byte[bytesPerLine()];

        encodeBufferPrefix(outStream);

        while (true) {
            numBytes = readFully(inStream, tmpbuffer);
            if (numBytes == 0) {
                break;
            }
            encodeLinePrefix(outStream, numBytes);
            for (j = 0; j < numBytes; j += bytesPerAtom()) {

                if ((j + bytesPerAtom()) <= numBytes) {
                    encodeAtom(outStream, tmpbuffer, j, bytesPerAtom());
                } else {
                    encodeAtom(outStream, tmpbuffer, j, (numBytes)- j);
                }
            }
            if (numBytes < bytesPerLine()) {
                break;
            } else {
                encodeLineSuffix(outStream);
            }
        }
        encodeBufferSuffix(outStream);
    }
520798
@GET
    @Produces(MediaType.TEXT_PLAIN)
    @RequiresPermissions(I18nPermissions.KEY_READ)
    public Response exportTranslations() {
        final List<Key> keys = keyRepository.loadAll();

        return Response.ok(new StreamingOutput() {

            private boolean isFirstLine = true;

            @Override
            public void write(OutputStream os) throws IOException {
                Writer writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
                for (Key key : keys) {
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    renderer.render(byteArrayOutputStream, key, APPLICATION_CSV, printHeader(isFirstLine));
                    writer.write(byteArrayOutputStream.toString("UTF-8"));
                    isFirstLine = false;
                }
                writer.flush();
            }
        }).header(CONTENT_DISPOSITION, ATTACHMENT_FILENAME_I18N_CSV).build();
    }
766713
@GwtIncompatible("Unnecessary")
  private Writer streamToOutputWriter2(OutputStream stream) {
    if (outputCharset2 == null) {
      return new BufferedWriter(new OutputStreamWriter(stream, UTF_8));
    } else {
      return new BufferedWriter(
          new OutputStreamWriter(stream, outputCharset2));
    }
  }
810638
public void reconstituteSourceStreams(int startMode,
                                        PtoPOutputHandler outputHandler) 
    throws SIDiscriminatorSyntaxException, MessageStoreException, SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, 
                  "reconstituteSourceStreams",
                  new Object[] { 
                  Integer.valueOf(startMode)});  

    _sourceProtocolItemStream.reconstituteSourceStreams( _baseDestinationHandler,
                                                         outputHandler, 
                                                         startMode);
  
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "reconstituteSourceStreams");
  }
228781
function(stream) {
		var exportKey = function(line, env) {
			var obj = JSON.parse(' ' + line);

			var keyString = keyStringGenerator(obj, env);

			return keyString + separator + line;
		};

		return stream.pipe(jp.map(exportKey));
	}
397179
public static void copyBufferedStream(BufferedInputStream sourceStream, BufferedOutputStream destinationStream,
			boolean closeStreams) throws IOException {
		byte[] buffer = new byte[8192];
		int bytesRead = 0;

		try {
			while ((bytesRead = sourceStream.read(buffer)) != -1) {
				destinationStream.write(buffer, 0, bytesRead);
			}
		} finally {
			if (closeStreams) {
				sourceStream.close();
				destinationStream.close();
			}
		}
	}
94478
@Override
    public SourceProtocolItemStream getSourceProtocolItemStream()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "getSourceProtocolItemStream");

        SourceProtocolItemStream sourceProtocolItemStream = _targetDestinationHandler.getSourceProtocolItemStream();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "getSourceProtocolItemStream", sourceProtocolItemStream);

        return sourceProtocolItemStream;
    }
198621
@Override
    public final void exportTo(final File target, final boolean overwrite) throws ArchiveExportException,
        FileExistsException {
        // Get stream and perform precondition checks
        final OutputStream out = this.getOutputStreamToFile(target, overwrite);

        try {
            // Write out
            this.exportTo(out);
        } finally {
            // Close
            try {
                out.close();
            } catch (final IOException ioe) {
                // Just log
                log.warning("Could not close " + out + ": " + ioe);
            }
        }
    }
81202
public void reconstituteSourceStreams(DestinationHandler dest, PtoPOutputHandler outputHandler, int startMode) 
  
  throws MessageStoreException, SIDiscriminatorSyntaxException, SIErrorException, SIResourceException
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "reconstituteSourceStreams", new Integer(startMode));

    
    /*
     * Iterate through all contained Protocol Items, looking for StreamSet
     * associated with source. Note that outputHandler passed in is null if this 
     * is Pubsub. 
     */ 
     
    SourceStreamSetFilter filter = null;
    if( dest.isPubSub())
    { 
      filter = new SourceStreamSetFilter(null);
    }
    else
    {
      filter = new SourceStreamSetFilter(outputHandler.getTargetMEUuid());
    }
    
    NonLockingCursor cursor = null;
    
    try
    {
      cursor = newNonLockingItemCursor(filter);    
           
	    AbstractItem item = null;
	    
	    //should only be one match!!
	    while (null != (item = cursor.next()))
	    {
	      StreamSet streamSet = (StreamSet)item;
          streamSet.initializeNonPersistent(dest.getTxManager());
	      
	      // Don't do flush if we are asked to start in recovery mode 
	      if(   ((startMode & JsConstants.ME_START_FLUSH ) == JsConstants.ME_START_FLUSH )
	         && ((startMode & JsConstants.ME_START_RECOVERY ) == 0 ) )
	      {
	        // Log message to console saying we have started flush for this steamSet
	        // parmeters are:- ME name, streamSet Uuid, destinationName
	        SibTr.info(
	          tc,
	          "FLUSH_INITIATED_MESSAGE_CWSIP0781",
	          new Object[] { dest.getMessageProcessor().getMessagingEngineName(),
	                        streamSet.getStreamID(),
	                        dest.getName() });
	      }
	      try
	      {
	        if( dest.isPubSub())
	        {
	          PubSubInputHandler inputHandler = (PubSubInputHandler)dest.getInputHandler();
	          inputHandler.reconstitutePubSubSourceStreams(streamSet, startMode);
	        }
	        else
	        {        
	          outputHandler.reconstitutePtoPSourceStreams(streamSet, startMode);
	        }
	      }
	      catch (SIResourceException e)
	      {
	        // FFDC
	        FFDCFilter.processException(
	          e,
	          "com.ibm.ws.sib.processor.impl.store.itemstreams.SourceProtocolItemStream.reconstituteSourceStreams",
	          "1:179:1.29",
	          this);
	        
	        // Don't do flush if we are asked to start in recovery mode 
	        if(   ((startMode & JsConstants.ME_START_FLUSH ) == JsConstants.ME_START_FLUSH )
	           && ((startMode & JsConstants.ME_START_RECOVERY ) == 0 ) )
	        {
	          // Log message to console saying flush for this steamSet has failed
	          // parmeters are:- ME name, streamSet Uuid, destinationName, exception.
	          SibTr.error(
	            tc,
	            "FLUSH_FAILED_MESSAGE_CWSIP0782",
	            new Object[] {dest.getMessageProcessor().getMessagingEngineName(),
	                          streamSet.getStreamID(),
	                          dest.getName(),
	                          e });
	        }
	        
	        // Rethrow exception after logging error
	        if (tc.isEntryEnabled()) SibTr.exit(tc, "reconstituteSourceStreams");
	        throw(e);
	      
	      }
	    }
    }
    finally
    {
      if (cursor != null)
        cursor.finished();
    }
    
    if (tc.isEntryEnabled())  
      SibTr.exit(tc, "reconstituteSourceStreams");      
  }
471139
@Override
    public ManifestDescriptor fromStream(InputStream in) throws IllegalArgumentException, DescriptorImportException {
        return fromStream(in, true);
    }
1078975
@Override
    public T from(final InputStream in, boolean close) throws IllegalArgumentException, DescriptorImportException {
        return this.fromStream(in, close);
    }
747071
@Override
    public String exportAsString() throws DescriptorExportException {
        // Export as bytes
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        this.exportTo(baos);

        // Make a String out of the bytes
        final String content;
        try {
            content = baos.toString(Charset.UTF8.name());
        } catch (final UnsupportedEncodingException e) {
            throw new DescriptorExportException("Inconsistent encoding used during export", e);
        }

        // Return
        return content;
    }
703076
static public void copyStream(InputStream is, OutputStream os) throws IOException {
		copyStream(is, os, DEFAULT_TRANSFER_BUFFER_SIZE);
	}
529963
@GwtIncompatible("Unnecessary")
  private Writer openExternExportsStream(B options, String path) throws IOException {
    if (options.externExportsPath == null) {
      return null;
    }

    String exPath = options.externExportsPath;

    if (!exPath.contains(File.separator)) {
      File outputFile = new File(path);
      exPath = outputFile.getParent() + File.separatorChar + exPath;
    }

    return fileNameToOutputWriter2(exPath);
  }
1217922
public void stream(InputStream inputStream, MediaType mediaType) {
        try {
            OutputStream outputStream = exchange.getOutputStream();
            setResponseMediaType(mediaType);

            byte[] buffer = new byte[10240];
            int len;
            while ((len = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, len);
            }
        } catch (Exception ex) {
            throw new RuntimeException("Error transferring data", ex);
        }
    }
40261
private static InputStream inputStreamFromJar(String relativePathPrefix, String src) throws IOException {
        String absoluteName = getAbsoluteName(relativePathPrefix, src);
        return XmlUtils.class.getResourceAsStream(absoluteName);
    }