Back to project page AndroidUploader.
The source code is released under:
Apache License
If you think the Android project AndroidUploader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package z.hol.uploader.bridge; //from w w w .j a va 2 s.c o m import java.io.IOException; import java.io.OutputStream; /** * ????? * Created by holmes on 10/15/14. */ public abstract class StreamBridge implements Bridge{ protected OutputStream outStream; private boolean mCloseStreamOnFinish = true; public StreamBridge(){ } /** * ???????? * ?????? this.outStream ?? * @param out */ public void setOutStream(OutputStream out){ outStream = out; } public void setCloseStreamOnFinish(boolean close){ mCloseStreamOnFinish = close; } public boolean isCloseStreamOnFinish(){ return mCloseStreamOnFinish; } @Override public int uploadData(byte[] data, int len) throws IOException { if (outStream == null){ throw new NullPointerException("outStream can not be null"); } int uploadLen = len > data.length ? data.length : len; outStream.write(data, 0, uploadLen); return uploadLen; } @Override public boolean finish() { if (mCloseStreamOnFinish){ if (outStream != null){ try { outStream.close(); } catch (IOException e) { e.printStackTrace(); return false; } } } return true; } }