Back to project page VideoExtand.
The source code is released under:
Apache License
If you think the Android project VideoExtand listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * //from w w w . j a v a 2s . c o m */ package com.yuninfo.videoextand.uploader; import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; /** * ?????????? * @author zhangyy@yuninfo.com * */ public class ProgressOutputStream extends FilterOutputStream { private ProgressListener<Long> mProgressListener = null; private long mContentLength = 0L; private long mProgress = 0L; public ProgressOutputStream(OutputStream out) { super(out); } public ProgressOutputStream(OutputStream out, long contentLength, final ProgressListener<Long> listener) { super(out); this.mProgressListener = listener; this.mContentLength = contentLength; this.mProgress = 0; } @Override public void write(byte[] buffer) throws IOException { out.write(buffer); mProgress += buffer.length; //????????????????????? if(mProgressListener != null) { mProgressListener.onProgressUpdate(mProgress, mContentLength); } } @Override public void write(byte[] buffer, int offset, int length) throws IOException { out.write(buffer, offset, length); mProgress += length; //????????????????????? if(mProgressListener != null) { mProgressListener.onProgressUpdate(mProgress, mContentLength); } } @Override public void write(int oneByte) throws IOException { out.write(oneByte); mProgress++; //????????????????????? if(mProgressListener != null) { mProgressListener.onProgressUpdate(mProgress, mContentLength); } } }