Example usage for com.google.common.io CountingOutputStream write

List of usage examples for com.google.common.io CountingOutputStream write

Introduction

In this page you can find the example usage for com.google.common.io CountingOutputStream write.

Prototype

@Override
    public void write(int b) throws IOException 

Source Link

Usage

From source file:com.tinspx.util.net.MultipartBody.java

private long doCopyTo(OutputStream output) throws IOException {
    assert checkNotEmpty();
    CountingOutputStream counter = new CountingOutputStream(output);
    counter.write(preamble);
    for (PartCache pc : partCache) {
        counter.write(pc.bytes);//from w  w w  .j a  v  a2 s  .  co  m
        pc.part.copyTo(counter);
    }
    counter.write(CRLF);
    counter.write(DASHDASH);
    counter.write(boundaryBytes);
    counter.write(DASHDASH);
    counter.write(CRLF);
    counter.write(epilogue);
    return counter.getCount();
}