@@ -0,0 +1,1165 @@
+/*%0A * Copyright (C) 2014, C. Ramakrishnan / Auracle.%0A * All rights reserved.%0A *%0A * This code is licensed under the BSD 3-Clause license.%0A * See file LICENSE (or LICENSE.html) for more information.%0A */%0A%0Apackage com.illposed.osc.utility;%0A%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0A%0A/**%0A * Keeps track of the number of bytes already written to the stream.%0A */%0Apublic class SizeTrackingOutputStream extends OutputStream %7B%0A%0A%09private final OutputStream wrappedStream;%0A%09private int writtenBytes;%0A%0A%09public SizeTrackingOutputStream(final OutputStream wrappedStream) %7B%0A%0A%09%09this.wrappedStream = wrappedStream;%0A%09%09this.writtenBytes = 0;%0A%09%7D%0A%0A%09public int size() %7B%0A%09%09return writtenBytes;%0A%09%7D%0A%0A%09public void reset() %7B%0A%09%09writtenBytes = 0;%0A%09%7D%0A%0A%09@Override%0A%09public void write(final int bty) throws IOException %7B%0A%09%09wrappedStream.write(bty);%0A%09%09writtenBytes++;%0A%09%7D%0A%0A%09@Override%0A%09public void write(final byte%5B%5D bytes) throws IOException %7B%0A%09%09wrappedStream.write(bytes);%0A%09%09writtenBytes += bytes.length;%0A%09%7D%0A%0A%09@Override%0A%09public void write(final byte%5B%5D bytes, final int off, final int len) throws IOException %7B%0A%09%09wrappedStream.write(bytes, off, len);%0A%09%09writtenBytes += len - off;%0A%09%7D%0A%7D%0A

introduce SizeTrackingOutputStream