@Nonnegative public static long copy (@Nonnull @WillClose final InputStream aIS, @Nonnull @WillNotClose final OutputStream aOS) { final MutableLong aML = new MutableLong (0); StreamHelper.copyInputStreamToOutputStream (aIS, aOS, aML); return aML.longValue (); }
StreamHelper.copyInputStreamToOutputStreamWithLimit (aIS, aMDNStream, nContentLength); else StreamHelper.copyInputStreamToOutputStream (aIS, aMDNStream);
/** * Stores the content of the input {@link InputStream} in a temporary file (in * the system temporary directory. * * @param aIS * {@link InputStream} to read from * @param sName * name to use in the temporary file to link it to the delivered * message. May be null * @return The created {@link File} * @throws IOException * in case of IO error */ @Nonnull protected static File storeContentToTempFile (@Nonnull final InputStream aIS, @Nonnull final String sName) throws IOException { // create temp file and write steam content to it // name may contain ":" on Windows and that would fail the tests! final String sSuffix = FilenameHelper.getAsSecureValidASCIIFilename (sName != null ? sName : "tmp"); final File aDestFile = File.createTempFile ("AS2TempSharedFileIS", sSuffix); try (final FileOutputStream aOS = new FileOutputStream (aDestFile)) { final MutableLong aCount = new MutableLong (0); StreamHelper.copyInputStreamToOutputStream (aIS, aOS, aCount); if (LOGGER.isInfoEnabled ()) LOGGER.info (aCount.longValue () + " bytes copied to " + aDestFile.getAbsolutePath ()); } return aDestFile; }
StreamHelper.copyInputStreamToOutputStreamWithLimit (aConnIS, aMDNStream, nContentLength); else StreamHelper.copyInputStreamToOutputStream (aConnIS, aMDNStream);
public static void copyStream (@WillNotClose final InputStream aIS, @WillNotClose final OutputStream aOS) { StreamHelper.copyInputStreamToOutputStream (new NonClosingInputStream (aIS), aOS); } }
/** * Reads the state of this object during deserialization. * * @param aOIS * The stream from which the state should be read. * @throws IOException * if an error occurs. * @throws ClassNotFoundException * if class cannot be found. */ private void readObject (@Nonnull final ObjectInputStream aOIS) throws IOException, ClassNotFoundException { // read values aOIS.defaultReadObject (); try (final OutputStream aOS = getOutputStream ()) { if (m_aCachedContent != null) { aOS.write (m_aCachedContent); } else { final InputStream aIS = FileHelper.getInputStream (m_aDFOSFile); StreamHelper.copyInputStreamToOutputStream (aIS, aOS); FileOperations.deleteFile (m_aDFOSFile); m_aDFOSFile = null; } } m_aCachedContent = null; }
/** * Writes the data from this output stream to the specified output stream, * after it has been closed. * * @param aOS * output stream to write to. * @exception IOException * if this stream is not yet closed or an error occurs. */ public void writeTo (@Nonnull @WillNotClose final OutputStream aOS) throws IOException { // we may only need to check if this is closed if we are working with a file // but we should force the habit of closing whether we are working with // a file or memory. if (!m_bClosed) throw new IOException ("This stream is not closed"); if (isInMemory ()) { m_aMemoryOS.writeTo (aOS); } else { final InputStream aIS = FileHelper.getInputStream (m_aOutputFile); StreamHelper.copyInputStreamToOutputStream (aIS, aOS); } } }
final MutableLong aByteCount = new MutableLong (0); if (StreamHelper.copyInputStreamToOutputStream (aContentIS, aOS, aByteCount).isSuccess ())
try (final OutputStream aOS = eCompressionMode.getCompressStream (FileHelper.getBufferedOutputStream (aRealFile))) StreamHelper.copyInputStreamToOutputStream (FileHelper.getBufferedInputStream (aSrcFile), aOS);
StreamHelper.copyInputStreamToOutputStream (aPart.getInputStream (), aData); aMdn.headers ().setContentLength (aData.size ());
StreamHelper.copyInputStreamToOutputStream (aMsg.getData ().getInputStream (), aFOS);