Search in sources :

Example 6 with CountingOutputStream

use of org.apache.commons.io.output.CountingOutputStream in project wso2-axis2-transports by wso2.

the class WSMimeMessage method writeTo.

@Override
public void writeTo(OutputStream out, String[] ignoreHeaders) throws MessagingException, IOException {
    if (bytesSent == -1) {
        CountingOutputStream countingOut = new CountingOutputStream(out);
        super.writeTo(countingOut, ignoreHeaders);
        bytesSent = countingOut.getByteCount();
    } else {
        super.writeTo(out, ignoreHeaders);
    }
}
Also used : CountingOutputStream(org.apache.commons.io.output.CountingOutputStream)

Example 7 with CountingOutputStream

use of org.apache.commons.io.output.CountingOutputStream in project jmeter by apache.

the class SmtpSampler method calculateMessageSize.

private long calculateMessageSize(Message message) throws IOException, MessagingException {
    if (getPropertyAsBoolean(MESSAGE_SIZE_STATS)) {
        // calculate message size
        CountingOutputStream cs = new CountingOutputStream(new NullOutputStream());
        message.writeTo(cs);
        return cs.getByteCount();
    } else {
        return -1L;
    }
}
Also used : CountingOutputStream(org.apache.commons.io.output.CountingOutputStream) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Aggregations

CountingOutputStream (org.apache.commons.io.output.CountingOutputStream)7 NullOutputStream (org.apache.commons.io.output.NullOutputStream)4 InputStream (java.io.InputStream)2 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 NullInputStream (org.apache.commons.io.input.NullInputStream)1 DelegatingServletOutputStream (org.apereo.portal.utils.DelegatingServletOutputStream)1 WriterOutputStream (org.kohsuke.stapler.framework.io.WriterOutputStream)1 Logger (org.slf4j.Logger)1